Commit 4d90923
committed
http: cast input to unsigned char in ragel parsers
The HTTP ragel state machines in src/http/{chunk_parsers,request_parser,
response_parser}.rl declare obs_text = 0x80..0xFF per RFC 7230 §3.2.6,
but the generated code compares (*p) directly where p is const char*.
On platforms whose ABI defines `char` as signed (x86_64) the 0x80..0xFF
range comparisons happen to land bytes on the obs_text state by way of
how negative chars sort against the literal byte values; on platforms
where `char` is unsigned (aarch64) the same bytes route through a
"byte > 122" path and the parser rejects valid input.
Add `getkey ((unsigned char)(*p));` to each machine so ragel emits an
explicit unsigned-char cast in every comparison. The fix is local to
the three .rl files; no compiler flag or input-buffer type change is
required.
This affects both seastar's HTTP server (http_request_parser via
include/seastar/http/httpd.hh) and its HTTP client
(http_response_parser via src/http/client.cc), so the bug surfaces on
any seastar-based service running on arm64 that receives or sends
obs_text in field values.
Fixes scylladb#3413.1 parent 21e446f commit 4d90923
3 files changed
Lines changed: 16 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
32 | 32 | | |
33 | 33 | | |
34 | 34 | | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
35 | 39 | | |
36 | 40 | | |
37 | 41 | | |
| |||
152 | 156 | | |
153 | 157 | | |
154 | 158 | | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
155 | 163 | | |
156 | 164 | | |
157 | 165 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
36 | 40 | | |
37 | 41 | | |
38 | 42 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
38 | 42 | | |
39 | 43 | | |
40 | 44 | | |
| |||
0 commit comments