Skip to content

Commit aeaed62

Browse files
committed
Add length check for read ChannelMonitor keys
1 parent 9abe4bb commit aeaed62

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

lightning/src/util/persist.rs

+6
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,12 @@ where
216216
for stored_key in kv_store.list(
217217
CHANNEL_MONITOR_PERSISTENCE_NAMESPACE, CHANNEL_MONITOR_PERSISTENCE_SUB_NAMESPACE)?
218218
{
219+
if stored_key.len() < 66 {
220+
return Err(io::Error::new(
221+
io::ErrorKind::InvalidData,
222+
"Stored key has invalid length"));
223+
}
224+
219225
let txid = Txid::from_hex(stored_key.split_at(64).0).map_err(|_| {
220226
io::Error::new(io::ErrorKind::InvalidData, "Invalid tx ID in stored key")
221227
})?;

0 commit comments

Comments
 (0)