diff options
Diffstat (limited to 'crypto/trace.c')
-rw-r--r-- | crypto/trace.c | 34 |
1 files changed, 31 insertions, 3 deletions
diff --git a/crypto/trace.c b/crypto/trace.c index 90a6350bebae..fbd4bf291401 100644 --- a/crypto/trace.c +++ b/crypto/trace.c @@ -18,6 +18,7 @@ #include "internal/nelem.h" #include "internal/refcount.h" #include "crypto/cryptlib.h" +#include "crypto/ctype.h" #ifndef OPENSSL_NO_TRACE @@ -137,8 +138,11 @@ static const struct trace_category_st TRACE_CATEGORY_(STORE), TRACE_CATEGORY_(DECODER), TRACE_CATEGORY_(ENCODER), - TRACE_CATEGORY_(REF_COUNT) -}; + TRACE_CATEGORY_(REF_COUNT), + TRACE_CATEGORY_(HTTP), + TRACE_CATEGORY_(PROVIDER), + TRACE_CATEGORY_(QUERY), +}; /* KEEP THIS LIST IN SYNC with #define OSSL_TRACE_CATEGORY_... in trace.h */ const char *OSSL_trace_get_category_name(int num) { @@ -500,7 +504,7 @@ BIO *OSSL_trace_begin(int category) return channel; } -void OSSL_trace_end(int category, BIO * channel) +void OSSL_trace_end(int category, BIO *channel) { #ifndef OPENSSL_NO_TRACE char *suffix = NULL; @@ -529,3 +533,27 @@ void OSSL_trace_end(int category, BIO * channel) } #endif } + +int OSSL_trace_string(BIO *out, int text, int full, + const unsigned char *data, size_t size) +{ + unsigned char buf[OSSL_TRACE_STRING_MAX + 1]; + int len, i; + + if (!full && size > OSSL_TRACE_STRING_MAX) { + BIO_printf(out, "[len %zu limited to %d]: ", + size, OSSL_TRACE_STRING_MAX); + len = OSSL_TRACE_STRING_MAX; + } else { + len = (int)size; + } + if (!text) { /* mask control characters while preserving newlines */ + for (i = 0; i < len; i++, data++) + buf[i] = (char)*data != '\n' && ossl_iscntrl((int)*data) + ? ' ' : *data; + if (len == 0 || data[-1] != '\n') + buf[len++] = '\n'; + data = buf; + } + return BIO_printf(out, "%.*s", len, data); +} |