Commit ee2be3d
fix(ui): clamp column width to avoid makeslice panic on huge -width (#101)
A user-supplied -width propagated unclamped into the side-by-side
renderer, where both truncPad (via runewidth.FillRight) and the divider
(strings.Repeat) would attempt a multi-gigabyte allocation and panic
with "makeslice: len out of range":
structalign -diff=side -width=4611686018427387904 ./pkg
Clamp the per-side width to maxColWidth (1<<16 cells, far wider than
any real terminal) inside truncPad - making the fuzzed function total -
and once in renderSideBySide so the divider shares the bound.
Found by fuzzing during the ClusterFuzzLite integration (#99):
fuzz_trunc_pad crashed within seconds in the OSS-Fuzz container. The
bug predates #94 - the old hand-rolled loop panicked identically in
strings.Repeat. After the fix the target runs 64k+ executions clean.
Closes #100
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>1 parent f4478e5 commit ee2be3d
2 files changed
Lines changed: 37 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
247 | 247 | | |
248 | 248 | | |
249 | 249 | | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
250 | 253 | | |
251 | 254 | | |
252 | 255 | | |
253 | 256 | | |
254 | 257 | | |
255 | 258 | | |
256 | | - | |
| 259 | + | |
257 | 260 | | |
258 | 261 | | |
259 | 262 | | |
260 | | - | |
| 263 | + | |
261 | 264 | | |
262 | | - | |
263 | | - | |
| 265 | + | |
| 266 | + | |
264 | 267 | | |
265 | 268 | | |
266 | 269 | | |
| |||
371 | 374 | | |
372 | 375 | | |
373 | 376 | | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
374 | 383 | | |
375 | 384 | | |
376 | 385 | | |
| 386 | + | |
377 | 387 | | |
378 | 388 | | |
379 | 389 | | |
380 | 390 | | |
| 391 | + | |
381 | 392 | | |
382 | 393 | | |
383 | 394 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
| 4 | + | |
| 5 | + | |
4 | 6 | | |
5 | 7 | | |
6 | 8 | | |
| |||
34 | 36 | | |
35 | 37 | | |
36 | 38 | | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
37 | 59 | | |
38 | 60 | | |
39 | 61 | | |
| |||
0 commit comments