You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
diff: -y --tabsize=<huge> overflows the column arithmetic (overflow-checks only) #264
SideDiffConfig::new (src/side_diff.rs) computes the side-by-side column layout with signed arithmetic on the --tabsize value:
let w = full_width asisize;let t = tab_size asisize;let t_plus_g = t + GUTTER_WIDTH_MINasisize;// <-- side_diff.rs:85: overflowslet unaligned_off = (w >> 1) + (t_plus_g >> 1) + (w & t_plus_g &1);let off = unaligned_off - unaligned_off % t;// (also % by t, and t can be 0)
--tabsize is parsed into tab_size: usize with no upper bound. A value near isize::MAX makes t + GUTTER_WIDTH_MIN (GUTTER_WIDTH_MIN == 3) overflow isize. Under -C overflow-checks=on this aborts (exit 134); in the default release build it wraps to a bogus value and the layout math silently produces garbage widths.
$ printf'a\n'> f1;printf'b\n'> f2
$ diff -y --tabsize=9223372036854775805 f1 f2 # overflow-checks buildthread 'main' panicked at src/side_diff.rs:85:24:attempt to add with overflow
$ echo$?134
Activity