From 3682dca7abdf49d26f9c57de449e17582004239d Mon Sep 17 00:00:00 2001 From: Matt Corallo Date: Sun, 27 Mar 2022 03:32:43 +0000 Subject: [PATCH] Avoid panic if chan IDs passed to {force,}closechannel isn't 32 bytes --- src/cli.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/cli.rs b/src/cli.rs index 88f8542..3d28fd1 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -320,8 +320,8 @@ pub(crate) async fn poll_for_user_input( continue; } let channel_id_vec = hex_utils::to_vec(channel_id_str.unwrap()); - if channel_id_vec.is_none() { - println!("ERROR: couldn't parse channel_id as hex"); + if channel_id_vec.is_none() || channel_id_vec.as_ref().unwrap().len() != 32 { + println!("ERROR: couldn't parse channel_id"); continue; } let mut channel_id = [0; 32]; @@ -335,8 +335,8 @@ pub(crate) async fn poll_for_user_input( continue; } let channel_id_vec = hex_utils::to_vec(channel_id_str.unwrap()); - if channel_id_vec.is_none() { - println!("ERROR: couldn't parse channel_id as hex"); + if channel_id_vec.is_none() || channel_id_vec.as_ref().unwrap().len() != 32 { + println!("ERROR: couldn't parse channel_id"); continue; } let mut channel_id = [0; 32]; -- 2.39.5