From 9de546e0ec8b77dbcb26f4500c337c3b2ae5f4ed Mon Sep 17 00:00:00 2001 From: aqua777 Date: Tue, 14 Feb 2023 11:04:42 +0000 Subject: [PATCH] Fixing map deserialization when header name or value is not a valid UTF8 string Signed-off-by: aqua777 --- src/hostcalls.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/hostcalls.rs b/src/hostcalls.rs index f1c47793..d2ef5eb3 100644 --- a/src/hostcalls.rs +++ b/src/hostcalls.rs @@ -1188,8 +1188,8 @@ mod utils { let value = bytes[p..p + size].to_vec(); p += size + 1; map.push(( - String::from_utf8(key).unwrap(), - String::from_utf8(value).unwrap(), + String::from_utf8(key).unwrap_or(String::from("?")), + String::from_utf8(value).unwrap_or(String::from("?")), )); } map @@ -1211,7 +1211,7 @@ mod utils { u32::from_le_bytes(<[u8; 4]>::try_from(&bytes[s + 4..s + 8]).unwrap()) as usize; let value = bytes[p..p + size].to_vec(); p += size + 1; - map.push((String::from_utf8(key).unwrap(), value)); + map.push((String::from_utf8(key).unwrap_or(String::from("?")), value)); } map }