Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

overflow on PartialEq for BigDecimal #93

Open
austinabell opened this issue Oct 11, 2022 · 0 comments
Open

overflow on PartialEq for BigDecimal #93

austinabell opened this issue Oct 11, 2022 · 0 comments

Comments

@austinabell
Copy link

The following lines:

let scaled_int_val = &rhs.int_val * ten_to_the((self.scale - rhs.scale) as u64);

let scaled_int_val = &self.int_val * ten_to_the((rhs.scale - self.scale) as u64);

overflow whenever either lhs or rhs are opposite signs and the abs sum is >u64::MAX

repro:

    let a = BigDecimal::new(bigdecimal::num_bigint::BigInt::from(1), i64::MIN);
    let b = BigDecimal::new(bigdecimal::num_bigint::BigInt::from(1), 1);
    let _ = a == b;

Found during fuzzing near/borsh-rs#91 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant