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)
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;
}
char *prefix = NULL;
category = ossl_trace_get_category(category);
+ if (category < 0)
+ return NULL;
+
channel = trace_channels[category].bio;
prefix = trace_channels[category].prefix;