]> git.bitcoin.ninja Git - rust-lightning/commit
Use consistent byte/char offsets when parsing invoice HRPs 2024-04-fuzz-bolt11
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:56:21 +0000 (19:56 +0000)
commit8db1226ae46b9c63275dcba1227e5d3c123fb258
tree0b6fa4ff41faf79e0f9b607d10b75406e76568d1
parent65ba75d500d7835b851e73cf572570e2b6056b39
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