Skip to content

Commit 1eeecb7

Browse files
committed
Fix off-by-one when looking for terminating NUL in find_pct_or_plus()
1 parent 2d231f4 commit 1eeecb7

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

src/lib/lwan-request.c

+2-4
Original file line numberDiff line numberDiff line change
@@ -293,11 +293,9 @@ static char *find_pct_or_plus(const char *input)
293293
uint64_t m = LWAN_MAX(has_plus, has_pct);
294294

295295
if (has_zero && LWAN_MAX(has_zero, m) == has_zero) {
296-
const int zero_pos = __builtin_ctzll(has_zero) / 8;
297-
if (zero_pos >= 1 && zero_pos <= 3)
296+
if (__builtin_ctzll(has_zero) / 8 < 4)
298297
goto check_small;
299-
if (zero_pos >= 4 && zero_pos <= 7)
300-
goto check_at_least_four;
298+
goto check_at_least_four;
301299
}
302300

303301
if (m) {

0 commit comments

Comments
 (0)