diff options
author | Rich Salz <rsalz@openssl.org> | 2015-04-30 23:48:31 +0200 |
---|---|---|
committer | Rich Salz <rsalz@openssl.org> | 2015-04-30 23:48:31 +0200 |
commit | 68dc682499ea3fe27d909c946d7abd39062d6efd (patch) | |
tree | 3478a6fb3699bdfa08d5871848696882ee1c24db /apps/srp.c | |
parent | free NULL cleanup 5a (diff) | |
download | openssl-68dc682499ea3fe27d909c946d7abd39062d6efd.tar.xz openssl-68dc682499ea3fe27d909c946d7abd39062d6efd.zip |
In apps, malloc or die
No point in proceeding if you're out of memory. So change
*all* OPENSSL_malloc calls in apps to use the new routine which
prints a message and exits.
Reviewed-by: Richard Levitte <levitte@openssl.org>
Diffstat (limited to 'apps/srp.c')
-rw-r--r-- | apps/srp.c | 21 |
1 files changed, 3 insertions, 18 deletions
diff --git a/apps/srp.c b/apps/srp.c index bbbe1a9873..b984c14c97 100644 --- a/apps/srp.c +++ b/apps/srp.c @@ -138,11 +138,7 @@ static int update_index(CA_DB *db, char **row) char **irow; int i; - if ((irow = OPENSSL_malloc(sizeof(char *) * (DB_NUMBER + 1))) == NULL) { - BIO_printf(bio_err, "Memory allocation failure\n"); - return 0; - } - + irow = app_malloc(sizeof(char *) * (DB_NUMBER + 1), "row pointers"); for (i = 0; i < DB_NUMBER; i++) { irow[i] = row[i]; row[i] = NULL; @@ -363,23 +359,12 @@ int srp_main(int argc, char **argv) configfile = getenv("SSLEAY_CONF"); if (configfile == NULL) { const char *s = X509_get_default_cert_area(); - size_t len; + size_t len = strlen(s) + 1 + sizeof(CONFIG_FILE); + tofree = app_malloc(len, "config filename space"); # ifdef OPENSSL_SYS_VMS - len = strlen(s) + sizeof(CONFIG_FILE); - tofree = OPENSSL_malloc(len); - if (!tofree) { - BIO_printf(bio_err, "Out of memory\n"); - goto end; - } strcpy(tofree, s); # else - len = strlen(s) + sizeof(CONFIG_FILE) + 1; - tofree = OPENSSL_malloc(len); - if (!tofree) { - BIO_printf(bio_err, "Out of memory\n"); - goto end; - } BUF_strlcpy(tofree, s, len); BUF_strlcat(tofree, "/", len); # endif |