summaryrefslogtreecommitdiffstats
path: root/crypto/err
diff options
context:
space:
mode:
authorMatt Caswell <matt@openssl.org>2019-11-26 17:15:20 +0000
committerMatt Caswell <matt@openssl.org>2019-11-29 14:21:55 +0000
commit17197a2f61d04314b465b71a4ce164b5e219f15c (patch)
treec29704c6ca5c958adb250a42581da3feabd9d3fb /crypto/err
parentc1ff5994407bc093eca78eb2fd4f813b7ee581a2 (diff)
Check the return from OPENSSL_buf2hexstr()
The function OPENSSL_buf2hexstr() can return NULL if it fails to allocate memory so the callers should check its return value. Fixes #10525 Reported-by: Ziyang Li (@Liby99) Reviewed-by: Matthias St. Pierre <Matthias.St.Pierre@ncp-e.com> (Merged from https://github.com/openssl/openssl/pull/10526)
Diffstat (limited to 'crypto/err')
-rw-r--r--crypto/err/err_prn.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/crypto/err/err_prn.c b/crypto/err/err_prn.c
index 27e987e0e1..e0184b0771 100644
--- a/crypto/err/err_prn.c
+++ b/crypto/err/err_prn.c
@@ -36,7 +36,8 @@ void ERR_print_errors_cb(int (*cb) (const char *str, size_t len, void *u),
data = "";
hex = OPENSSL_buf2hexstr((const unsigned char *)&tid, sizeof(tid));
BIO_snprintf(buf, sizeof(buf), "%s:error:%s:%s:%s:%s:%d:%s\n",
- hex, lib, func, reason, file, line, data);
+ hex == NULL ? "<null>" : hex, lib, func, reason, file,
+ line, data);
OPENSSL_free(hex);
if (cb(buf, strlen(buf), u) <= 0)
break; /* abort outputting the error report */