X-Git-Url: https://git.openssl.org/?p=openssl.git;a=blobdiff_plain;f=apps%2Fs_cb.c;h=442b33556817e789e4fe9b0d9d7f5771217b3afb;hp=1d026b6514ad531c5c11885a4571739c03f650be;hb=86885c289580066792415218754bd935b449f170;hpb=222561fe8ef510f336417a666f69f81ddc9b8fe4 diff --git a/apps/s_cb.c b/apps/s_cb.c index 1d026b6514..442b335568 100644 --- a/apps/s_cb.c +++ b/apps/s_cb.c @@ -439,11 +439,7 @@ int ssl_print_curves(BIO *out, SSL *s, int noshared) ncurves = SSL_get1_curves(s, NULL); if (ncurves <= 0) return 1; - curves = OPENSSL_malloc(ncurves * sizeof(int)); - if (!curves) { - BIO_printf(out, "Out of memory\n"); - return 0; - } + curves = app_malloc(ncurves * sizeof(int), "curves to print"); SSL_get1_curves(s, curves); BIO_puts(out, "Supported Elliptic Curves: "); @@ -955,12 +951,7 @@ int generate_cookie_callback(SSL *ssl, unsigned char *cookie, OPENSSL_assert(0); break; } - buffer = OPENSSL_malloc(length); - - if (buffer == NULL) { - BIO_printf(bio_err, "out of memory\n"); - return 0; - } + buffer = app_malloc(length, "cookie generate buffer"); switch (peer.sa.sa_family) { case AF_INET: @@ -1028,12 +1019,7 @@ int verify_cookie_callback(SSL *ssl, unsigned char *cookie, OPENSSL_assert(0); break; } - buffer = OPENSSL_malloc(length); - - if (buffer == NULL) { - BIO_printf(bio_err, "out of memory\n"); - return 0; - } + buffer = app_malloc(length, "cookie verify buffer"); switch (peer.sa.sa_family) { case AF_INET: @@ -1187,10 +1173,8 @@ void ssl_ctx_set_excert(SSL_CTX *ctx, SSL_EXCERT *exc) static int ssl_excert_prepend(SSL_EXCERT **pexc) { - SSL_EXCERT *exc; - exc = OPENSSL_malloc(sizeof(SSL_EXCERT)); - if (!exc) - return 0; + SSL_EXCERT *exc = app_malloc(sizeof(*exc), "prepend cert"); + exc->certfile = NULL; exc->keyfile = NULL; exc->chainfile = NULL; @@ -1218,6 +1202,9 @@ static int ssl_excert_prepend(SSL_EXCERT **pexc) void ssl_excert_free(SSL_EXCERT *exc) { SSL_EXCERT *curr; + + if (!exc) + return; while (exc) { X509_free(exc->cert); EVP_PKEY_free(exc->key); @@ -1327,8 +1314,7 @@ int args_excert(int opt, SSL_EXCERT **pexc) err: ERR_print_errors(bio_err); - if (exc) - ssl_excert_free(exc); + ssl_excert_free(exc); *pexc = NULL; return 0; } @@ -1406,10 +1392,10 @@ int config_ctx(SSL_CONF_CTX *cctx, STACK_OF(OPENSSL_STRING) *str, const char *flag = sk_OPENSSL_STRING_value(str, i); const char *arg = sk_OPENSSL_STRING_value(str, i + 1); /* If no_ecdhe or named curve already specified don't need a default. */ - if (!no_ecdhe && !strcmp(flag, "-named_curve")) + if (!no_ecdhe && strcmp(flag, "-named_curve") == 0) no_ecdhe = 1; #ifndef OPENSSL_NO_JPAKE - if (!no_jpake && !strcmp(flag, "-cipher")) { + if (!no_jpake && (strcmp(flag, "-cipher") == 0)) { BIO_puts(bio_err, "JPAKE sets cipher to PSK\n"); return 0; }