Skip to content

Fix crash due to index-out-of-bounds in Feature context-translation #1002

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

Conversation

valentinewallace
Copy link
Contributor

This was reported by a user when trying to send a payment using the LDK
sample (specifically during route generation IIUC).

@codecov
Copy link

codecov bot commented Jul 14, 2021

Codecov Report

Merging #1002 (7497ed2) into main (afae12e) will increase coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #1002   +/-   ##
=======================================
  Coverage   90.78%   90.78%           
=======================================
  Files          60       60           
  Lines       30914    30915    +1     
=======================================
+ Hits        28064    28065    +1     
  Misses       2850     2850           
Impacted Files Coverage Δ
lightning/src/ln/features.rs 99.71% <100.00%> (+<0.01%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update afae12e...7497ed2. Read the comment docs.

Copy link
Contributor

@jkczyz jkczyz left a comment

Choose a reason for hiding this comment

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

nit: update commit summary s/parsing/translation and state what the problem was in the description.

let mut flags = Vec::new();
for (i, byte) in self.flags.iter().enumerate() {
if i < byte_count {
if i < from_byte_count && i < to_byte_count {
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you add a test case?

Copy link
Contributor Author

@valentinewallace valentinewallace Jul 14, 2021

Choose a reason for hiding this comment

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

I can later but won't have time this week. Asked Matt and he's fine with me PR'ing a test separately later, lmk what you think.

Copy link
Contributor

Choose a reason for hiding this comment

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

No prob. I don't mind doing it if you want to get this merged in the meantime.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That would be awesome! 🙏

This was reported by a user when trying to send a payment using the LDK
sample (specifically during route generation when translating a Features
from one context to another)

The problem was we didn't check T::KNOWN_FEATURE_MASK vec length before
indexing into it, due likely to the assumption that known feature vec
lengths are the same across contexts, when they may not be
@valentinewallace valentinewallace force-pushed the 2021-07-fix-features-index-bounds branch from 5bdc22e to 7497ed2 Compare July 14, 2021 22:56
@TheBlueMatt TheBlueMatt merged commit ccd7b6c into lightningdevkit:main Jul 15, 2021
@decentclock
Copy link

decentclock commented Jul 15, 2021

Can confirm this solves the issue I reported ( sendpayment crashed on an invoice generated by c-lightning ). Thanks for the quick fix !

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