diff options
author | Daniel Fiala <daniel@openssl.org> | 2022-08-05 04:44:51 +0200 |
---|---|---|
committer | Tomas Mraz <tomas@openssl.org> | 2023-01-11 15:06:38 +0100 |
commit | 5c6936e92df88828ed58c678f86b555b5413e858 (patch) | |
tree | 18ed2a7b1e955f44f072f0d34432ea508a10bdb1 /crypto | |
parent | 2f2176dc8d38f0248c748c11d992fa595d15f88c (diff) |
Add tests for trace_api.
Fixes openssl#17422
Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(cherry picked from commit fcff5bd43c85418cc4aa8052e3dc3dba344d763e)
Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/19958)
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 */ } |