Skip to content

Commit

Permalink
fixup! fixup! fixup! replace various calls to sprintf() by BiO_snprin…
Browse files Browse the repository at this point in the history
…tf() to avoid compiler warnings, e.g., on MacOS
  • Loading branch information
DDvO committed Oct 9, 2024
1 parent 9700dc8 commit 36a46c9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
13 changes: 6 additions & 7 deletions crypto/dso/dso_win32.c
Original file line number Diff line number Diff line change
Expand Up @@ -444,21 +444,20 @@ static char *win32_name_converter(DSO *dso, const char *filename)
char *translated;
int len, transform;

len = strlen(filename);
transform = ((strstr(filename, "/") == NULL) &&
(strstr(filename, "\\") == NULL) &&
(strstr(filename, ":") == NULL));
/* If transform != 0, then we convert to %s.dll, else just dupe filename */

len = strlen(filename) + 1;
if (transform)
/* We will convert this to "%s.dll" */
translated = OPENSSL_malloc(len + 5);
else
/* We will simply duplicate filename */
translated = OPENSSL_malloc(len + 1);
len += strlen(".dll");
translated = OPENSSL_malloc(len);
if (translated == NULL) {
ERR_raise(ERR_LIB_DSO, DSO_R_NAME_TRANSLATION_FAILED);
return NULL;
}
BIO_snprintf(translated, len + 1, transform ? "%s.dll" : "%s", filename);
BIO_snprintf(translated, len, "%s%s", filename, transform ? ".dll" : "");
return translated;
}

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 + BIO_snprintf(max, sizeof (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 36a46c9

Please sign in to comment.