Skip to content

Commit 4fa7983

Browse files
committed
psbt: Fix unsigned integer overflow
1 parent 5057adf commit 4fa7983

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/psbt.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -893,6 +893,9 @@ struct PSBTOutput
893893
s >> leaf_hashes;
894894
size_t after_hashes = s.size();
895895
size_t hashes_len = before_hashes - after_hashes;
896+
if (hashes_len > value_len) {
897+
throw std::ios_base::failure("Output Taproot BIP32 keypath has an invalid length");
898+
}
896899
size_t origin_len = value_len - hashes_len;
897900
m_tap_bip32_paths.emplace(xonly, std::make_pair(leaf_hashes, DeserializeKeyOrigin(s, origin_len)));
898901
break;

0 commit comments

Comments
 (0)