summaryrefslogtreecommitdiffstats
path: root/crypto/params.c
diff options
context:
space:
mode:
authorMatt Caswell <matt@openssl.org>2020-04-28 17:45:53 +0100
committerMatt Caswell <matt@openssl.org>2020-05-04 09:30:55 +0100
commitb756626a3732869875c50f150bddacfbcac5a7ab (patch)
tree62d02e9b5410657f71b5a19358cb99cf5cf3e3d7 /crypto/params.c
parent86dc26baf65dd2ba83beff80ce37d05a3f6c33b0 (diff)
Allow OSSL_PARAM_get_octet_string() to pass a NULL buffer
We may just want to know the number of octets so allow passing a NULL buffer. Reviewed-by: Shane Lontis <shane.lontis@oracle.com> (Merged from https://github.com/openssl/openssl/pull/11635)
Diffstat (limited to 'crypto/params.c')
-rw-r--r--crypto/params.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/crypto/params.c b/crypto/params.c
index 32161d0533..06ae1bc44f 100644
--- a/crypto/params.c
+++ b/crypto/params.c
@@ -780,7 +780,7 @@ static int get_string_internal(const OSSL_PARAM *p, void **val, size_t max_len,
{
size_t sz;
- if (val == NULL || p == NULL || p->data_type != type)
+ if ((val == NULL && used_len == NULL) || p == NULL || p->data_type != type)
return 0;
sz = p->data_size;
@@ -793,6 +793,9 @@ static int get_string_internal(const OSSL_PARAM *p, void **val, size_t max_len,
if (p->data == NULL)
return 0;
+ if (val == NULL)
+ return 1;
+
if (*val == NULL) {
char *const q = OPENSSL_malloc(sz);