From 68dc682499ea3fe27d909c946d7abd39062d6efd Mon Sep 17 00:00:00 2001 From: Rich Salz Date: Thu, 30 Apr 2015 17:48:31 -0400 Subject: 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 --- apps/srp.c | 21 +++------------------ 1 file changed, 3 insertions(+), 18 deletions(-) (limited to 'apps/srp.c') 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 -- cgit v1.2.3