Skip to content

Conversation

@GHOryy5
Copy link

@GHOryy5 GHOryy5 commented Dec 15, 2025

This PR removes an unchecked unwrap() in the lender claim calculation
that could cause the program to panic under arithmetic edge cases.

Details

The redeemable amount calculation previously relied on unwrap() when
converting from u128 to u64. While the inputs are expected to be safe
under normal conditions, malformed or extreme values could trigger a
panic, resulting in a hard denial-of-service for the instruction.

This change replaces the unwrap() with checked arithmetic and explicit
error handling, returning a program error instead of panicking

@crypto-vincent
Copy link
Contributor

crypto-vincent commented Dec 16, 2025

Hello there, this looks like a pretty reasonable change, in a vacuum. But there is a few reason why this might be unecessary.

  1. Could you expand on the statement:

resulting in a hard denial-of-service for the instruction

It looks like this PR just makes the error returned more idiomatic, returning the error instead of panic, in both cases however the instruction will fail.

  1. Also could you confirm that this PR does indeed compile ? I don't see any "ProgramError::MathOverflow" value.

  2. Additionally, could you expand on what this PR adds compared to compiling with the overflow-checks = true, which automatically inject this sort of checks already

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

Successfully merging this pull request may close these issues.

2 participants