Commit 5e3fee8
committed
fix: panic in linear myers algorithm
In `linearSpaceMyersRecWithIndices`, the suffix-scanning loop:
```go
for suffix < n-prefix && a[aEnd-1-suffix] == b[bEnd-1-suffix] {
```
bounds the scan against n-prefix (a's remaining length after prefix) but not against m-prefix (b's remaining length).
With the fuzzer's input a="\n\n\n\n\n\n\n\n\n0" → 10 lines, b="0" → 1 line:
n=10, m=1, prefix=0
suffix=0: a[9]="0" == b[0]="0" → true, suffix becomes 1
suffix=1: tries b[1-1-1] = b[-1] → index out of range panic
Signed-off-by: Andrey Smirnov <andrey.smirnov@siderolabs.com>1 parent a1f8b87 commit 5e3fee8
1 file changed
Lines changed: 2 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
207 | 207 | | |
208 | 208 | | |
209 | 209 | | |
210 | | - | |
| 210 | + | |
211 | 211 | | |
212 | 212 | | |
213 | 213 | | |
| |||
217 | 217 | | |
218 | 218 | | |
219 | 219 | | |
220 | | - | |
| 220 | + | |
221 | 221 | | |
222 | 222 | | |
223 | 223 | | |
| |||
0 commit comments