Skip to content

Commit

Permalink
Fix off-by-one when looking for terminating NUL in find_pct_or_plus()
Browse files Browse the repository at this point in the history
  • Loading branch information
lpereira committed May 25, 2024
1 parent 2d231f4 commit 1eeecb7
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions src/lib/lwan-request.c
Original file line number Diff line number Diff line change
Expand Up @@ -293,11 +293,9 @@ static char *find_pct_or_plus(const char *input)
uint64_t m = LWAN_MAX(has_plus, has_pct);

if (has_zero && LWAN_MAX(has_zero, m) == has_zero) {
const int zero_pos = __builtin_ctzll(has_zero) / 8;
if (zero_pos >= 1 && zero_pos <= 3)
if (__builtin_ctzll(has_zero) / 8 < 4)
goto check_small;
if (zero_pos >= 4 && zero_pos <= 7)
goto check_at_least_four;
goto check_at_least_four;
}

if (m) {
Expand Down

0 comments on commit 1eeecb7

Please sign in to comment.