From: Matt Caswell Date: Fri, 11 Oct 2019 16:42:19 +0000 (+0100) Subject: Allow setting a NULL pointer in a params structure X-Git-Tag: openssl-3.0.0-alpha1~961 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=b3f3ba7011c9afa3ac3b5ebf0c7462fb6ddee2cd;p=oweals%2Fopenssl.git Allow setting a NULL pointer in a params structure Sometimes it is valid to send a NULL pointer in params. Reviewed-by: Richard Levitte (Merged from https://github.com/openssl/openssl/pull/10152) --- diff --git a/crypto/params.c b/crypto/params.c index 0cd13e3b81..58a4710e47 100644 --- a/crypto/params.c +++ b/crypto/params.c @@ -892,9 +892,8 @@ int OSSL_PARAM_set_utf8_ptr(OSSL_PARAM *p, const char *val) if (p == NULL) return 0; p->return_size = 0; - if (val == NULL) - return 0; - return set_ptr_internal(p, val, OSSL_PARAM_UTF8_PTR, strlen(val) + 1); + return set_ptr_internal(p, val, OSSL_PARAM_UTF8_PTR, + val == NULL ? 0 : strlen(val) + 1); } int OSSL_PARAM_set_octet_ptr(OSSL_PARAM *p, const void *val, @@ -903,8 +902,6 @@ int OSSL_PARAM_set_octet_ptr(OSSL_PARAM *p, const void *val, if (p == NULL) return 0; p->return_size = 0; - if (val == NULL) - return 0; return set_ptr_internal(p, val, OSSL_PARAM_OCTET_PTR, used_len); }