From b3f3ba7011c9afa3ac3b5ebf0c7462fb6ddee2cd Mon Sep 17 00:00:00 2001 From: Matt Caswell Date: Fri, 11 Oct 2019 17:42:19 +0100 Subject: [PATCH] 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) --- crypto/params.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) 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); } -- 2.25.1