summaryrefslogtreecommitdiffstats
path: root/ssl
diff options
context:
space:
mode:
authordyrock <zeyuany@gmail.com>2019-04-15 11:01:58 -0500
committerMatt Caswell <matt@openssl.org>2019-04-19 09:55:47 +0100
commit1711a62686e3d55767ba067a4fd1a18ceec69d3f (patch)
tree57b7199801c27e17791a1b19c9de784be5160a9a /ssl
parentaf0bab32273847c14ea7635f714466a5d497905c (diff)
Check if num is 0 before trying to malloc memory. Otherwise for client hellos without extensions SSL_client_hello_get1_extensions_present will return MALLOC_FAILURE.
Reviewed-by: Paul Yang <yang.yang@baishancloud.com> Reviewed-by: Ben Kaduk <kaduk@mit.edu> Reviewed-by: Matt Caswell <matt@openssl.org> (Merged from https://github.com/openssl/openssl/pull/8756) (cherry picked from commit 6fda11ae5a06e28fd9463e5afb60735d074904b3)
Diffstat (limited to 'ssl')
-rw-r--r--ssl/ssl_lib.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/ssl/ssl_lib.c b/ssl/ssl_lib.c
index 4440a9ffe9..d7e1f328d6 100644
--- a/ssl/ssl_lib.c
+++ b/ssl/ssl_lib.c
@@ -5070,6 +5070,11 @@ int SSL_client_hello_get1_extensions_present(SSL *s, int **out, size_t *outlen)
if (ext->present)
num++;
}
+ if (num == 0) {
+ *out = NULL;
+ *outlen = 0;
+ return 1;
+ }
if ((present = OPENSSL_malloc(sizeof(*present) * num)) == NULL) {
SSLerr(SSL_F_SSL_CLIENT_HELLO_GET1_EXTENSIONS_PRESENT,
ERR_R_MALLOC_FAILURE);