Skip to content

common/amount: prevent scaling with invalid factors in amount scale functions#8306

Merged
rustyrussell merged 1 commit intoElementsProject:masterfrom
Chand-ra:amount-scale
Sep 15, 2025
Merged

common/amount: prevent scaling with invalid factors in amount scale functions#8306
rustyrussell merged 1 commit intoElementsProject:masterfrom
Chand-ra:amount-scale

Conversation

@Chand-ra
Copy link

Add checks in amount_msat_scale() and amount_sat_scale() to return false when the scaling factor is -NaN or negative.

This is important as the scaling factor may come from external sources like wire, which can cause runtime errors if not handled properly.

Checklist

Before submitting the PR, ensure the following tasks are completed. If an item is not applicable to your PR, please mark it as checked:

  • The changelog has been updated in the relevant commit(s) according to the guidelines.
  • Tests have been added or modified to reflect the changes.
  • Documentation has been reviewed and updated as needed.
  • Related issues have been listed and linked, including any that this PR closes.

…unctions

Changelog-Fixed: Add checks in `amount_msat_scale` and
`amount_sat_scale` to return false when the scaling factor
is -NaN or negative.

This is important as the scaling factor may come from external
sources like wire, which can cause runtime errors if not handled
properly.
@cdecker
Copy link
Member

cdecker commented Jun 12, 2025

ACK 2bd8caf

Copy link
Contributor

@morehouse morehouse left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK 2bd8caf

@rustyrussell rustyrussell merged commit 43516ce into ElementsProject:master Sep 15, 2025
40 checks passed
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.

4 participants