]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemu: Check for valid save image format when verifying image header
authorJim Fehlig via Devel <devel@lists.libvirt.org>
Fri, 31 Jan 2025 02:29:04 +0000 (19:29 -0700)
committerMichal Privoznik <mprivozn@redhat.com>
Fri, 31 Jan 2025 07:53:51 +0000 (08:53 +0100)
When attempting to restore a saved image, the check for a valid save image
format does not occur until the qemu process is about to be executed. Move
the check earlier in the restore process, along with the other checks that
verify a valid save image header.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
src/qemu/qemu_saveimage.c

index 8315171b786547602e0d468b3d80f724ef9d645c..5c889fee11c891b27f2ea2e46c1a1a83664f7d69 100644 (file)
@@ -289,6 +289,12 @@ qemuSaveImageReadHeader(int fd, virQEMUSaveData **ret_data)
         return -1;
     }
 
+    if (header->format >= QEMU_SAVE_FORMAT_LAST) {
+        virReportError(VIR_ERR_OPERATION_FAILED,
+                       _("unsupported save image format: %1$d"), header->format);
+        return -1;
+    }
+
     if (header->data_len <= 0) {
         virReportError(VIR_ERR_OPERATION_FAILED,
                        _("invalid header data length: %1$d"), header->data_len);