]> git.proxmox.com Git - proxmox.git/commitdiff
schema: don't accept unterminated quoted strings
authorWolfgang Bumiller <w.bumiller@proxmox.com>
Wed, 9 Mar 2022 12:41:09 +0000 (13:41 +0100)
committerWolfgang Bumiller <w.bumiller@proxmox.com>
Wed, 9 Mar 2022 12:41:09 +0000 (13:41 +0100)
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
proxmox-schema/src/property_string.rs

index a40c1ca12ce427daa3e76f1e4d3ca01e3d10b25d..964ac4f02ea884f2f4cc1fa1237cf6e64e75b32b 100644 (file)
@@ -109,7 +109,11 @@ fn parse_quoted_string<'s>(data: &'_ mut &'s str) -> Result<Cow<'s, str>, 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());
 }