Skip to content

Commit

Permalink
trace: fix out-of-bound memory access
Browse files Browse the repository at this point in the history
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 <[email protected]>
(Merged from openssl#8552)
  • Loading branch information
mspncp committed Mar 29, 2019
1 parent 0fda9f7 commit 6a41143
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion crypto/trace.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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;

Expand Down

0 comments on commit 6a41143

Please sign in to comment.