Skip to content

Commit

Permalink
fixup! fixup! replace various calls to sprintf() by BiO_snprintf() to…
Browse files Browse the repository at this point in the history
… avoid compiler warnings, e.g., on MacOS
  • Loading branch information
DDvO committed Sep 28, 2024
1 parent 9cf399e commit 9700dc8
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 21 deletions.
10 changes: 5 additions & 5 deletions apps/lib/vms_term_sock.c
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ static int CreateSocketPair (int SocketFamily,
/*
** Get the binary (64-bit) time of the specified timeout value
*/
sprintf (AscTimeBuff, "0 0:0:%02d.00", SOCKET_PAIR_TIMEOUT_VALUE);
BIO_snprintf(AscTimeBuff, sizeof(AscTimeBuff), "0 0:0:%02d.00", SOCKET_PAIR_TIMEOUT_VALUE);
AscTimeDesc.dsc$w_length = strlen (AscTimeBuff);
AscTimeDesc.dsc$a_pointer = AscTimeBuff;
status = sys$bintim (&AscTimeDesc, BinTimeBuff);
Expand Down Expand Up @@ -567,10 +567,10 @@ static void LogMessage (char *msg, ...)
/*
** Format the message buffer
*/
sprintf (MsgBuff, "%02d-%s-%04d %02d:%02d:%02d [%08X] %s\n",
LocTime->tm_mday, Month[LocTime->tm_mon],
(LocTime->tm_year + 1900), LocTime->tm_hour, LocTime->tm_min,
LocTime->tm_sec, pid, msg);
BIO_snprintf(MsgBuff, sizeof(MsgBuff), "%02d-%s-%04d %02d:%02d:%02d [%08X] %s\n",
LocTime->tm_mday, Month[LocTime->tm_mon],
(LocTime->tm_year + 1900), LocTime->tm_hour, LocTime->tm_min,
LocTime->tm_sec, pid, msg);

/*
** Get any variable arguments and add them to the print of the message
Expand Down
2 changes: 1 addition & 1 deletion crypto/bio/bss_log.c
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ static void xsyslog(BIO *bp, int priority, const char *string)
break;
}

sprintf(pidbuf, "[%lu] ", GetCurrentProcessId());
BIO_snprintf(pidbuf, sizeof(pidbuf), "[%lu] ", GetCurrentProcessId());
lpszStrings[0] = pidbuf;
lpszStrings[1] = string;

Expand Down
13 changes: 6 additions & 7 deletions crypto/dso/dso_dl.c
Original file line number Diff line number Diff line change
Expand Up @@ -229,13 +229,12 @@ static char *dl_name_converter(DSO *dso, const char *filename)
ERR_raise(ERR_LIB_DSO, DSO_R_NAME_TRANSLATION_FAILED);
return NULL;
}
if (transform) {
if ((DSO_flags(dso) & DSO_FLAG_NAME_TRANSLATION_EXT_ONLY) == 0)
sprintf(translated, "lib%s%s", filename, DSO_EXTENSION);
else
sprintf(translated, "%s%s", filename, DSO_EXTENSION);
} else
sprintf(translated, "%s", filename);
if (transform)
BIO_snprintf(translated, rsize,
(DSO_flags(dso) & DSO_FLAG_NAME_TRANSLATION_EXT_ONLY) == 0
? "lib%s%s" : "%s%s", filename, DSO_EXTENSION);
else
BIO_snprintf(translated, rsize, "%s", filename);
return translated;
}

Expand Down
5 changes: 1 addition & 4 deletions crypto/dso/dso_win32.c
Original file line number Diff line number Diff line change
Expand Up @@ -458,10 +458,7 @@ static char *win32_name_converter(DSO *dso, const char *filename)
ERR_raise(ERR_LIB_DSO, DSO_R_NAME_TRANSLATION_FAILED);
return NULL;
}
if (transform)
sprintf(translated, "%s.dll", filename);
else
sprintf(translated, "%s", filename);
BIO_snprintf(translated, len + 1, transform ? "%s.dll" : "%s", filename);
return translated;
}

Expand Down
6 changes: 3 additions & 3 deletions crypto/info.c
Original file line number Diff line number Diff line change
Expand Up @@ -190,10 +190,10 @@ DEFINE_RUN_ONCE_STATIC(init_info_strings)
#endif
#ifndef OPENSSL_NO_JITTER
{
char jent_version_string[32];
char buf[32];

sprintf(jent_version_string, "JITTER (%d)", jent_version());
add_seeds_string(jent_version_string);
BIO_snprintf(buf, sizeof(buf), "JITTER (%d)", jent_version());
add_seeds_string(buf);
}
#endif
seed_sources = seeds;
Expand Down
2 changes: 1 addition & 1 deletion test/conf_include_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ static int test_check_overflow(void)
char max[(sizeof(long) * 8) / 3 + 3];
char *p;

p = max + sprintf(max, "0%ld", LONG_MAX) - 1;
p = max + BIO_snprintf(max, sizeof (max), "0%ld", LONG_MAX) - 1;
setenv("FNORD", max, 1);
if (!TEST_true(NCONF_get_number(NULL, "missing", "FNORD", &val))
|| !TEST_long_eq(val, LONG_MAX))
Expand Down

0 comments on commit 9700dc8

Please sign in to comment.