From b466bde5d0fd8daf989c3809f3def93369139d1a Mon Sep 17 00:00:00 2001 From: Daniel Pouzzner Date: Tue, 4 Feb 2025 12:07:29 -0600 Subject: [PATCH] src/internal.c and src/ssl.c: in CheckcipherList() and ParseCipherList(), refactor "while (next++)" to "while (next)" to avoid clang21 UndefinedBehaviorSanitizer "applying non-zero offset 1 to null pointer". --- src/internal.c | 4 ++-- src/ssl.c | 13 +++++++++---- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/internal.c b/src/internal.c index 3a375ccc4..0c8f34743 100644 --- a/src/internal.c +++ b/src/internal.c @@ -27822,6 +27822,7 @@ static int ParseCipherList(Suites* suites, } if (currLen == 0) break; + ++next; /* increment to skip ':' */ } #if defined(OPENSSL_EXTRA) || defined(OPENSSL_ALL) @@ -28173,8 +28174,7 @@ static int ParseCipherList(Suites* suites, break; } } - } - while (next++); /* increment to skip ':' */ + } while (next); if (ret) { int keySz = 0; diff --git a/src/ssl.c b/src/ssl.c index babe37fe8..d684f19a9 100644 --- a/src/ssl.c +++ b/src/ssl.c @@ -9221,8 +9221,14 @@ static int CheckcipherList(const char* list) next = XSTRSTR(next, ":"); - current_length = (!next) ? (word32)XSTRLEN(current) - : (word32)(next - current); + if (next) { + current_length = (word32)(next - current); + ++next; /* increment to skip ':' */ + } + else { + current_length = (word32)XSTRLEN(current); + } + if (current_length == 0) { break; } @@ -9279,8 +9285,7 @@ static int CheckcipherList(const char* list) /* list has mixed suites */ return 0; } - } - while (next++); /* increment to skip ':' */ + } while (next); if (findTLSv13Suites == 0 && findbeforeSuites == 1) { ret = 1;/* only before TLSv13 suites */