Commit 2bcbc39
committed
common/json: fix out-of-bounds slice in the comment scanner
skipJSONString advances i by 2 on a backslash escape; when the backslash is the
last byte of the input, i is pushed past len(data) and returned unchanged. A
caller then slices data[keyStart:keyEnd] with keyEnd > len(data), panicking with
"slice bounds out of range". This is reachable from any untrusted JSON parsed by
the comment-aware decoder (e.g. a sing-box config or rule-set), e.g. the 12-byte
input {0000000#00000\n\ crashes it.
Clamp the returned index to len(data). Add FuzzUnmarshalExtended.1 parent 59379fe commit 2bcbc39
2 files changed
Lines changed: 23 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
211 | 211 | | |
212 | 212 | | |
213 | 213 | | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
214 | 219 | | |
215 | 220 | | |
216 | 221 | | |
| |||
0 commit comments