diff options
author | Daniel Fiala <daniel@openssl.org> | 2022-08-05 04:44:51 +0200 |
---|---|---|
committer | Tomas Mraz <tomas@openssl.org> | 2022-11-23 18:21:43 +0100 |
commit | 9099a0564be5a01c120f1dd6f0693910fa0cb126 (patch) | |
tree | 94cb4fbb1b4908140bdb978df6ff1280cd9c9e78 /crypto | |
parent | 24e1432e187a3ee3b902cb7dcf379344e40dd70d (diff) |
Add tests for trace_api.
Fixes openssl#17422
Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/19096)
(cherry picked from commit fcff5bd43c85418cc4aa8052e3dc3dba344d763e)
Diffstat (limited to 'crypto')
-rw-r--r-- | crypto/trace.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/crypto/trace.c b/crypto/trace.c index d790409a2d..ec6c8f5e29 100644 --- a/crypto/trace.c +++ b/crypto/trace.c @@ -145,9 +145,19 @@ const char *OSSL_trace_get_category_name(int num) { size_t i; + /* + * Partial check that OSSL_TRACE_CATEGORY_... macros + * are synced with trace_categories array + */ +#ifndef OPENSSL_NO_ENGINE + if (!ossl_assert(OSSL_TRACE_CATEGORY_NUM == OSSL_NELEM(trace_categories))) + return NULL; +#endif + for (i = 0; i < OSSL_NELEM(trace_categories); i++) if (trace_categories[i].num == num) return trace_categories[i].name; + return NULL; /* not found */ } @@ -155,9 +165,13 @@ int OSSL_trace_get_category_num(const char *name) { size_t i; + if (name == NULL) + return -1; + for (i = 0; i < OSSL_NELEM(trace_categories); i++) if (OPENSSL_strcasecmp(name, trace_categories[i].name) == 0) return trace_categories[i].num; + return -1; /* not found */ } |