]> xenbits.xensource.com Git - libvirt.git/commitdiff
storage_file_probe: change maximum len value in vmdk4GetBackingStore
authorAnastasia Belova <abelova@astralinux.ru>
Wed, 29 Mar 2023 10:09:02 +0000 (13:09 +0300)
committerJán Tomko <jtomko@redhat.com>
Wed, 29 Mar 2023 11:02:01 +0000 (13:02 +0200)
desc length should be always less than VIR_STORAGE_MAX_HEADER.
If len = VIR_STORAGE_MAX_HEADER, desc may be out of bounds.

Fixes: 296032bfb2 ("util: extract storage file probe code into virtstoragefileprobe.c")
Signed-off-by: Anastasia Belova <abelova@astralinux.ru>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
src/storage_file/storage_file_probe.c

index 9465af5d96ce354b9a9ea7b6a0cf00540363e87b..0dcc9c2c54d5f51a1ee9f1c11e21f734cd36f032 100644 (file)
@@ -586,8 +586,8 @@ vmdk4GetBackingStore(char **res,
         return BACKING_STORE_INVALID;
 
     len = buf_size - 0x200;
-    if (len > VIR_STORAGE_MAX_HEADER)
-        len = VIR_STORAGE_MAX_HEADER;
+    if (len >= VIR_STORAGE_MAX_HEADER)
+        len = VIR_STORAGE_MAX_HEADER - 1;
     memcpy(desc, buf + 0x200, len);
     desc[len] = '\0';
     start = strstr(desc, prefix);