diff --git a/common/bolt11.c b/common/bolt11.c index a168d66e5c30..c6eb0bd8f2bc 100644 --- a/common/bolt11.c +++ b/common/bolt11.c @@ -76,7 +76,11 @@ static const char *pull_uint(struct hash_u5 *hu5, err = pull_bits(hu5, data, data_len, &be_val, databits, true); if (err) return err; - *val = be64_to_cpu(be_val) >> (sizeof(be_val) * CHAR_BIT - databits); + if (databits == 0) + *val = 0; + else + *val = be64_to_cpu(be_val) >> + (sizeof(be_val) * CHAR_BIT - databits); return NULL; } diff --git a/tests/fuzz/corpora/fuzz-bolt11-decode/crash-ad3693f6c454ce739ca67a4aff234cb3f3f598b5 b/tests/fuzz/corpora/fuzz-bolt11-decode/crash-ad3693f6c454ce739ca67a4aff234cb3f3f598b5 new file mode 100644 index 000000000000..a37d233f51ce --- /dev/null +++ b/tests/fuzz/corpora/fuzz-bolt11-decode/crash-ad3693f6c454ce739ca67a4aff234cb3f3f598b5 @@ -0,0 +1 @@ +lnltc1zzzzzAzcQQQQQZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZXZZZZZZZZZZZZZZZZZJZZZZZZZZZZzzzZZZZZZZZ \ No newline at end of file