diff options
author | Dr. Matthias St. Pierre <Matthias.St.Pierre@ncp-e.com> | 2019-03-21 00:56:36 +0100 |
---|---|---|
committer | Dr. Matthias St. Pierre <Matthias.St.Pierre@ncp-e.com> | 2019-03-29 23:59:46 +0100 |
commit | 6a411436a5642a4c2ca934a649eced7118f3793d (patch) | |
tree | 393cd93cd7f4d95e8bf9ba6688a1d7790c03386b /crypto/trace.c | |
parent | 0fda9f7c291de7b3a1e576ce43801dfa91b42f0e (diff) |
trace: fix out-of-bound memory access
When OSSL_trace_get_category_num() is called with an unknown category
name, it returns -1. This case needs to be considered in order to
avoid out-of-bound memory access to the `trace_channels` array.
Reviewed-by: Paul Dale <paul.dale@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/8552)
Diffstat (limited to 'crypto/trace.c')
-rw-r--r-- | crypto/trace.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/crypto/trace.c b/crypto/trace.c index 6299a688be..5e2fec299a 100644 --- a/crypto/trace.c +++ b/crypto/trace.c @@ -431,7 +431,8 @@ int OSSL_trace_enabled(int category) int ret = 0; #ifndef OPENSSL_NO_TRACE category = ossl_trace_get_category(category); - ret = trace_channels[category].bio != NULL; + if (category >= 0) + ret = trace_channels[category].bio != NULL; #endif return ret; } @@ -443,6 +444,9 @@ BIO *OSSL_trace_begin(int category) char *prefix = NULL; category = ossl_trace_get_category(category); + if (category < 0) + return NULL; + channel = trace_channels[category].bio; prefix = trace_channels[category].prefix; |