Skip to content

Commit a297a58

Browse files
authored
Merge pull request #909 from tnull/2026-05-check-even-len-hex
Reject malformed (odd-length) hex strings
2 parents 7281b35 + 8189984 commit a297a58

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

src/hex_utils.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@ use std::fmt::Write;
99

1010
#[cfg(feature = "uniffi")]
1111
pub fn to_vec(hex: &str) -> Option<Vec<u8>> {
12+
// Reject malformed hex strings.
13+
if hex.len() % 2 != 0 {
14+
return None;
15+
}
16+
1217
let mut out = Vec::with_capacity(hex.len() / 2);
1318

1419
let mut b = 0;

0 commit comments

Comments
 (0)