Allow strings in params to be of zero length
authorMatt Caswell <matt@openssl.org>
Thu, 17 Oct 2019 16:19:21 +0000 (17:19 +0100)
committerMatt Caswell <matt@openssl.org>
Thu, 14 Nov 2019 09:29:21 +0000 (09:29 +0000)
Sometimes it is useful to be able to pass NULL/zero length strings

Reviewed-by: Richard Levitte <levitte@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/10152)

crypto/params.c

index 58a4710e47828137d7dbdad18b6b8195d5f5c697..5d1fc6a6f2d1ea4290d172d593a7b7ab8bd17196 100644 (file)
@@ -776,6 +776,9 @@ static int get_string_internal(const OSSL_PARAM *p, void **val, size_t max_len,
     if (used_len != NULL)
         *used_len = sz;
 
+    if (sz == 0)
+        return 1;
+
     if (*val == NULL) {
         char *const q = OPENSSL_malloc(sz);