Skip to content

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

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

rustyrussell merged 1 commit into
ElementsProject:masterfrom
Chand-ra:amount-scale

Conversation

@Chand-ra

Copy link
Copy Markdown

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

cdecker commented Jun 12, 2025

Copy link
Copy Markdown
Member

ACK 2bd8caf

@morehouse morehouse left a comment

Copy link
Copy Markdown
Contributor

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
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