From: Matt Corallo Date: Sat, 26 Mar 2022 20:28:57 +0000 (+0000) Subject: Add a bounds check before accessing a user-provided PK string X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=commitdiff_plain;h=147435bfe69b5ebf0af451795db84b5a25d8b383;p=ldk-sample Add a bounds check before accessing a user-provided PK string Fixes #53. --- diff --git a/src/hex_utils.rs b/src/hex_utils.rs index 70fe28b..0eee5af 100644 --- a/src/hex_utils.rs +++ b/src/hex_utils.rs @@ -31,6 +31,9 @@ pub fn hex_str(value: &[u8]) -> String { } pub fn to_compressed_pubkey(hex: &str) -> Option { + if hex.len() != 33 * 2 { + return None; + } let data = match to_vec(&hex[0..33 * 2]) { Some(bytes) => bytes, None => return None,