-
Notifications
You must be signed in to change notification settings - Fork 50
Arithmetic overflow found on wrap_columns() #517
Copy link
Copy link
Open
Description
I executed fuzzing with textwrap-0.16.0. Proper panic message should be added by assert! or need to use checked operations.
Thread '<unnamed>' panicked at 'attempt to multiply with overflow', textwrap-0.16.0/src/lib.rs:1173
pub fn wrap_columns<'a, Opt>(
text: &str,
columns: usize,
total_width_or_options: Opt,
left_gap: &str,
middle_gap: &str,
right_gap: &str,
) -> Vec<String>
where
Opt: Into<Options<'a>>,
{
assert!(columns > 0);
let mut options: Options = total_width_or_options.into();
let inner_width = options
.width
.saturating_sub(core::display_width(left_gap))
.saturating_sub(core::display_width(right_gap))
.saturating_sub(core::display_width(middle_gap) * (columns - 1)); // overflow!
reproduce with :
let mut fuzz_arg0: &str = "J";
let mut fuzz_arg1: &str = "\u{8}\n\0?@";
let mut fuzz_arg2: &str = "";
let mut fuzz_arg3: usize = 17788374102109585368;
let mut fuzz_arg4: &str = "";
let mut fuzz_arg5: usize = 0;
wrap_columns(fuzz_arg0, fuzz_arg3, fuzz_arg5, fuzz_arg2, fuzz_arg1, fuzz_arg4);
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels