Skip to content

Commit 147435b

Browse files
committed
Add a bounds check before accessing a user-provided PK string
Fixes lightningdevkit#53.
1 parent 719ac73 commit 147435b

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/hex_utils.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ pub fn hex_str(value: &[u8]) -> String {
3131
}
3232

3333
pub fn to_compressed_pubkey(hex: &str) -> Option<PublicKey> {
34+
if hex.len() != 33 * 2 {
35+
return None;
36+
}
3437
let data = match to_vec(&hex[0..33 * 2]) {
3538
Some(bytes) => bytes,
3639
None => return None,

0 commit comments

Comments
 (0)