]> git.bitcoin.ninja Git - rust-lightning/commit
Use consistent byte/char offsets when parsing invoice HRPs
authorMatt Corallo <git@bluematt.me>
Tue, 30 Apr 2024 17:11:54 +0000 (17:11 +0000)
committerMatt Corallo <git@bluematt.me>
Wed, 8 May 2024 19:31:50 +0000 (19:31 +0000)
commit30a208eda65f87c9c13aeec6dd4c2e2b22e8add4
tree0ec00dfe64a038ec6783a5a3a80d50fa620a9e37
parent092485014167dc10849cfeda521796ae5101ba90
Use consistent byte/char offsets when parsing invoice HRPs

When parsing lightning-invoice HRPs we want to read them
char-by-char, tracking at which offset different fields were. Prior
to this commit this was done first by reading char-by-char and then
by indexing using the byte offset which works for ASCII strings but
fails on multi-byte characters.

This commit fixes this issue by simply always walking byte-by-byte
and rejecting multi-byte characters which don't belong in HRPs.
lightning-invoice/src/de.rs