From d7283d5aeb64529003897200a082fd407b167f5a Mon Sep 17 00:00:00 2001 From: Wolfgang Bumiller Date: Wed, 9 Mar 2022 13:41:09 +0100 Subject: [PATCH] schema: don't accept unterminated quoted strings Signed-off-by: Wolfgang Bumiller --- proxmox-schema/src/property_string.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/proxmox-schema/src/property_string.rs b/proxmox-schema/src/property_string.rs index a40c1ca1..964ac4f0 100644 --- a/proxmox-schema/src/property_string.rs +++ b/proxmox-schema/src/property_string.rs @@ -109,7 +109,11 @@ fn parse_quoted_string<'s>(data: &'_ mut &'s str) -> Result, Error> out.extend_from_slice(&data[1..i]); i += 1; let mut was_backslash = true; - while i != data.len() { + loop { + if i == data.len() { + bail!("unexpected end of string"); + } + match (data[i], mem::replace(&mut was_backslash, false)) { (b'"', false) => { i += 1; @@ -160,4 +164,6 @@ fn iterate_over_property_string() { (None, Cow::Borrowed(r#"and " and '\'"#)) ); assert!(iter.next().is_none()); + + assert!(PropertyIterator::new(r#"key="open \\ value"#).next().unwrap().is_err()); }