From 53b65182c1ffcad3db26bd5f1c1edaf9c64b44d0 Mon Sep 17 00:00:00 2001 From: Martin Zeithaml Date: Thu, 25 Jul 2024 16:09:55 +0200 Subject: [PATCH 1/3] Debug message enhancement Signed-off-by: Martin Zeithaml --- c/tls.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/c/tls.c b/c/tls.c index 70af67fbe..7bf6f714b 100644 --- a/c/tls.c +++ b/c/tls.c @@ -90,7 +90,7 @@ static int getTlsMax(TlsSettings *settings) { if (settings->maxTls != NULL) { for (int i = 0; i < TLS_NAMES_LENGTH; i++) { if (!strcmp(settings->maxTls, TLS_NAMES[i])) { - zowelog(NULL, LOG_COMP_HTTPSERVER, ZOWE_LOG_DEBUG, "Min TLS requested=%d\n",i); + zowelog(NULL, LOG_COMP_HTTPSERVER, ZOWE_LOG_DEBUG, "Min TLS requested=%s\n", TLS_NAMES[i]); return i; } } @@ -103,7 +103,7 @@ static int getTlsMin(TlsSettings *settings) { if (settings->minTls != NULL) { for (int i = 0; i < TLS_NAMES_LENGTH; i++) { if (!strcmp(settings->minTls, TLS_NAMES[i])) { - zowelog(NULL, LOG_COMP_HTTPSERVER, ZOWE_LOG_DEBUG, "Max TLS requested=%d\n",i); + zowelog(NULL, LOG_COMP_HTTPSERVER, ZOWE_LOG_DEBUG, "Max TLS requested=%s\n", TLS_NAMES[i]); return i; } } From 8bc7ae789f61bdef91455afe4fcd016d93145d2b Mon Sep 17 00:00:00 2001 From: Martin Zeithaml Date: Thu, 25 Jul 2024 16:26:05 +0200 Subject: [PATCH 2/3] Rename TLS_NAMES_LENGTH and use it Signed-off-by: Martin Zeithaml --- c/tls.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/c/tls.c b/c/tls.c index 7bf6f714b..e9c99cf7d 100644 --- a/c/tls.c +++ b/c/tls.c @@ -76,7 +76,8 @@ static int isTLSV13Available(TlsSettings *settings) { #define TLS_MIN_DEFAULT TLS_V1_2 #define TLS_MAX_DEFAULT TLS_V1_3 -static char *TLS_NAMES[5] = { +#define TLS_NAMES_COUNT 5 +static char *TLS_NAMES[TLS_NAMES_COUNT] = { "invalid", "TLSv1.0", "TLSv1.1", @@ -84,11 +85,9 @@ static char *TLS_NAMES[5] = { "TLSv1.3" }; -#define TLS_NAMES_LENGTH 5 - static int getTlsMax(TlsSettings *settings) { if (settings->maxTls != NULL) { - for (int i = 0; i < TLS_NAMES_LENGTH; i++) { + for (int i = 0; i < TLS_NAMES_COUNT; i++) { if (!strcmp(settings->maxTls, TLS_NAMES[i])) { zowelog(NULL, LOG_COMP_HTTPSERVER, ZOWE_LOG_DEBUG, "Min TLS requested=%s\n", TLS_NAMES[i]); return i; @@ -101,7 +100,7 @@ static int getTlsMax(TlsSettings *settings) { static int getTlsMin(TlsSettings *settings) { if (settings->minTls != NULL) { - for (int i = 0; i < TLS_NAMES_LENGTH; i++) { + for (int i = 0; i < TLS_NAMES_COUNT; i++) { if (!strcmp(settings->minTls, TLS_NAMES[i])) { zowelog(NULL, LOG_COMP_HTTPSERVER, ZOWE_LOG_DEBUG, "Max TLS requested=%s\n", TLS_NAMES[i]); return i; From 28bcae834bff7b02fed7bb9632f724927d2f4115 Mon Sep 17 00:00:00 2001 From: Martin Zeithaml Date: Fri, 29 Nov 2024 12:53:28 +0100 Subject: [PATCH 3/3] Independent number of elements Signed-off-by: Martin Zeithaml --- c/tls.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/c/tls.c b/c/tls.c index e9c99cf7d..60e3446fc 100644 --- a/c/tls.c +++ b/c/tls.c @@ -76,8 +76,7 @@ static int isTLSV13Available(TlsSettings *settings) { #define TLS_MIN_DEFAULT TLS_V1_2 #define TLS_MAX_DEFAULT TLS_V1_3 -#define TLS_NAMES_COUNT 5 -static char *TLS_NAMES[TLS_NAMES_COUNT] = { +static char *TLS_NAMES[] = { "invalid", "TLSv1.0", "TLSv1.1", @@ -87,7 +86,7 @@ static char *TLS_NAMES[TLS_NAMES_COUNT] = { static int getTlsMax(TlsSettings *settings) { if (settings->maxTls != NULL) { - for (int i = 0; i < TLS_NAMES_COUNT; i++) { + for (int i = 0; i < sizeof(TLS_NAMES)/sizeof(TLS_NAMES[0]); i++) { if (!strcmp(settings->maxTls, TLS_NAMES[i])) { zowelog(NULL, LOG_COMP_HTTPSERVER, ZOWE_LOG_DEBUG, "Min TLS requested=%s\n", TLS_NAMES[i]); return i; @@ -100,7 +99,7 @@ static int getTlsMax(TlsSettings *settings) { static int getTlsMin(TlsSettings *settings) { if (settings->minTls != NULL) { - for (int i = 0; i < TLS_NAMES_COUNT; i++) { + for (int i = 0; i < sizeof(TLS_NAMES)/sizeof(TLS_NAMES[0]); i++) { if (!strcmp(settings->minTls, TLS_NAMES[i])) { zowelog(NULL, LOG_COMP_HTTPSERVER, ZOWE_LOG_DEBUG, "Max TLS requested=%s\n", TLS_NAMES[i]); return i;