From 889c8f41f78df3dbb24311c7b11286d76fb7089f Mon Sep 17 00:00:00 2001 From: Andras Fekete Date: Thu, 26 Sep 2024 12:45:59 -0400 Subject: [PATCH] Allow the sniffer to print the trace to STDOUT --- src/sniffer.c | 14 +++++++++----- sslSniffer/README.md | 2 +- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/sniffer.c b/src/sniffer.c index 6921e07a0f..e4ceb4984e 100644 --- a/src/sniffer.c +++ b/src/sniffer.c @@ -6866,11 +6866,15 @@ int ssl_Trace(const char* traceFile, char* error) if (traceFile) { /* Don't try to reopen the file */ if (TraceFile == NULL) { - TraceFile = XFOPEN(traceFile, "a"); - if (!TraceFile) { - SetError(BAD_TRACE_FILE_STR, error, NULL, 0); - return WOLFSSL_FATAL_ERROR; - } + if (XSTRCMP(traceFile, "-") == 0) { + TraceFile = stdout; + } else { + TraceFile = XFOPEN(traceFile, "a"); + if (!TraceFile) { + SetError(BAD_TRACE_FILE_STR, error, NULL, 0); + return WOLFSSL_FATAL_ERROR; + } + } TraceOn = 1; } } diff --git a/sslSniffer/README.md b/sslSniffer/README.md index 27a6f52781..dbf68955ed 100644 --- a/sslSniffer/README.md +++ b/sslSniffer/README.md @@ -197,7 +197,7 @@ Frees all resources consumed by the wolfSSL sniffer and should be called when us int ssl_Trace(const char* traceFile, char* error); ``` -Enables Tracing when a file is passed in. Disables Tracing if previously on and a NULL value is passed in for the file. +Enables Tracing when a file is passed in. When `traceFile` is "-", then the trace will be printed to STDOUT. Disables Tracing if previously on and a NULL value is passed in for the file. Returns Values: