summaryrefslogtreecommitdiff
path: root/crypto
diff options
context:
space:
mode:
authorTomas Mraz <tomas@openssl.org>2021-04-19 16:02:16 +0200
committerTomas Mraz <tomas@openssl.org>2021-04-22 16:46:20 +0200
commit1fac27050176f7ed00da5649266024265678f70c (patch)
tree4b60cd18f6793a759f49fa08146b44e98575398f /crypto
parentdb6b1266ab30945de2d14fbc62e9c3c308cce897 (diff)
downloadopenssl-new-1fac27050176f7ed00da5649266024265678f70c.tar.gz
Fix potential NULL dereference in OSSL_PARAM_get_utf8_string()
Fixes Coverity ID 1476283 Reviewed-by: Paul Dale <pauli@openssl.org> (Merged from https://github.com/openssl/openssl/pull/14928)
Diffstat (limited to 'crypto')
-rw-r--r--crypto/params.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/crypto/params.c b/crypto/params.c
index 50e900a406..d9743633b0 100644
--- a/crypto/params.c
+++ b/crypto/params.c
@@ -1128,11 +1128,13 @@ int OSSL_PARAM_get_utf8_string(const OSSL_PARAM *p, char **val, size_t max_len)
*/
size_t data_length = p->data_size;
+ if (ret == 0)
+ return 0;
if (data_length >= max_len)
data_length = OPENSSL_strnlen(p->data, data_length);
if (data_length >= max_len)
return 0; /* No space for a terminating NUL byte */
- ((char *)*val)[data_length] = '\0';
+ (*val)[data_length] = '\0';
return ret;
}