Skip to content

Fix max-value overflows in set_max_path_length #3522

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

Merged

Conversation

TheBlueMatt
Copy link
Collaborator

When either the amount or the max_total_cltv_expiry_delta are set to max-value, set_max_path_length can trigger overflows in build_onion_payloads_callback, leading to debug-panics.

Copy link
Contributor

@valentinewallace valentinewallace left a comment

Choose a reason for hiding this comment

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

CI is sad. LGTM though!

@@ -1607,4 +1610,19 @@ mod tests {
writer.write_all(&self.data[..])
}
}

#[test]
fn max_length_with_no_cltv_limit() {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can this go in max_path_len_tests.rs?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Could do...Generally we haven't shied away from doing unit tests in the same module that we're testing, at least for modules that aren't 10k LoC already 😅...

Copy link

codecov bot commented Jan 11, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 89.01%. Comparing base (463e432) to head (8bf4dd6).
Report is 17 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3522      +/-   ##
==========================================
+ Coverage   88.34%   89.01%   +0.66%     
==========================================
  Files         149      149              
  Lines      112915   116907    +3992     
  Branches   112915   116907    +3992     
==========================================
+ Hits        99753   104061    +4308     
+ Misses      10685    10417     -268     
+ Partials     2477     2429      -48     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@TheBlueMatt TheBlueMatt force-pushed the 2025-01-overflow-cltv branch from 8bf4dd6 to 8b5cd47 Compare January 12, 2025 18:22
@TheBlueMatt TheBlueMatt added this to the 0.1 milestone Jan 12, 2025
@TheBlueMatt
Copy link
Collaborator Author

Tagging this 0.1 since it currently causes some of the Java bindings tests to fail, so its easier if we get it in before the release.

When either the amount or the `max_total_cltv_expiry_delta` are
set to max-value, `set_max_path_length` can trigger overflows in
`build_onion_payloads_callback`, leading to debug-panics.
@TheBlueMatt TheBlueMatt force-pushed the 2025-01-overflow-cltv branch from 8b5cd47 to 3e88b32 Compare January 13, 2025 14:51
@valentinewallace valentinewallace merged commit 5f68d71 into lightningdevkit:main Jan 13, 2025
16 of 19 checks passed
@TheBlueMatt TheBlueMatt mentioned this pull request Jan 14, 2025
@TheBlueMatt
Copy link
Collaborator Author

Backported in #3536.

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.

None yet

2 participants