[openssl-commits] [openssl] master update
Matt Caswell
matt at openssl.org
Tue May 29 16:13:51 UTC 2018
The branch master has been updated
via 02a7e0a9f63ec97e9671fec2bb8ce7c289fb4d66 (commit)
from 47eaa32d2671c1b608200afb97cc2f0040053686 (commit)
- Log -----------------------------------------------------------------
commit 02a7e0a9f63ec97e9671fec2bb8ce7c289fb4d66
Author: Todd Short <tshort at akamai.com>
Date: Tue May 22 10:48:04 2018 -0400
Replace strdup() with OPENSSL_strdup()
It's freed with OPENSSL_free()
Reviewed-by: Andy Polyakov <appro at openssl.org>
Reviewed-by: Matt Caswell <matt at openssl.org>
(Merged from https://github.com/openssl/openssl/pull/6331)
-----------------------------------------------------------------------
Summary of changes:
apps/rehash.c | 14 +++++++++-----
1 file changed, 9 insertions(+), 5 deletions(-)
diff --git a/apps/rehash.c b/apps/rehash.c
index 521bf61..de7217c 100644
--- a/apps/rehash.c
+++ b/apps/rehash.c
@@ -308,7 +308,7 @@ static int do_dir(const char *dirname, enum Hash h)
size_t i;
const char *pathsep;
const char *filename;
- char *buf, *copy;
+ char *buf, *copy = NULL;
STACK_OF(OPENSSL_STRING) *files = NULL;
if (app_access(dirname, W_OK) < 0) {
@@ -325,13 +325,16 @@ static int do_dir(const char *dirname, enum Hash h)
if ((files = sk_OPENSSL_STRING_new_null()) == NULL) {
BIO_printf(bio_err, "Skipping %s, out of memory\n", dirname);
- exit(1);
+ errs = 1;
+ goto err;
}
while ((filename = OPENSSL_DIR_read(&d, dirname)) != NULL) {
- if ((copy = strdup(filename)) == NULL
+ if ((copy = OPENSSL_strdup(filename)) == NULL
|| sk_OPENSSL_STRING_push(files, copy) == 0) {
+ OPENSSL_free(copy);
BIO_puts(bio_err, "out of memory\n");
- exit(1);
+ errs = 1;
+ goto err;
}
}
OPENSSL_DIR_end(&d);
@@ -349,7 +352,6 @@ static int do_dir(const char *dirname, enum Hash h)
continue;
errs += do_file(filename, buf, h);
}
- sk_OPENSSL_STRING_pop_free(files, str_free);
for (i = 0; i < OSSL_NELEM(hash_table); i++) {
for (bp = hash_table[i]; bp; bp = nextbp) {
@@ -417,6 +419,8 @@ static int do_dir(const char *dirname, enum Hash h)
hash_table[i] = NULL;
}
+ err:
+ sk_OPENSSL_STRING_pop_free(files, str_free);
OPENSSL_free(buf);
return errs;
}
More information about the openssl-commits
mailing list