Skip to content

Commit b466bde

Browse files
committed
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".
1 parent 6141b50 commit b466bde

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

src/internal.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27822,6 +27822,7 @@ static int ParseCipherList(Suites* suites,
2782227822
}
2782327823
if (currLen == 0)
2782427824
break;
27825+
++next; /* increment to skip ':' */
2782527826
}
2782627827

2782727828
#if defined(OPENSSL_EXTRA) || defined(OPENSSL_ALL)
@@ -28173,8 +28174,7 @@ static int ParseCipherList(Suites* suites,
2817328174
break;
2817428175
}
2817528176
}
28176-
}
28177-
while (next++); /* increment to skip ':' */
28177+
} while (next);
2817828178

2817928179
if (ret) {
2818028180
int keySz = 0;

src/ssl.c

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9221,8 +9221,14 @@ static int CheckcipherList(const char* list)
92219221

92229222
next = XSTRSTR(next, ":");
92239223

9224-
current_length = (!next) ? (word32)XSTRLEN(current)
9225-
: (word32)(next - current);
9224+
if (next) {
9225+
current_length = (word32)(next - current);
9226+
++next; /* increment to skip ':' */
9227+
}
9228+
else {
9229+
current_length = (word32)XSTRLEN(current);
9230+
}
9231+
92269232
if (current_length == 0) {
92279233
break;
92289234
}
@@ -9279,8 +9285,7 @@ static int CheckcipherList(const char* list)
92799285
/* list has mixed suites */
92809286
return 0;
92819287
}
9282-
}
9283-
while (next++); /* increment to skip ':' */
9288+
} while (next);
92849289

92859290
if (findTLSv13Suites == 0 && findbeforeSuites == 1) {
92869291
ret = 1;/* only before TLSv13 suites */

0 commit comments

Comments
 (0)