diff --git a/crypto/dso/dso_win32.c b/crypto/dso/dso_win32.c index 6fb06469cfebdd..085ddef9695be8 100644 --- a/crypto/dso/dso_win32.c +++ b/crypto/dso/dso_win32.c @@ -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; } diff --git a/test/conf_include_test.c b/test/conf_include_test.c index 4a28ddafe54c4a..2b16c6ebe49d44 100644 --- a/test/conf_include_test.c +++ b/test/conf_include_test.c @@ -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))