]> git.ipfire.org Git - thirdparty/libvirt.git/commit
util: storage: Fix qcow(2) header parser according to docs
authorPeter Krempa <pkrempa@redhat.com>
Mon, 15 Sep 2014 14:16:25 +0000 (16:16 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Tue, 16 Sep 2014 07:19:57 +0000 (09:19 +0200)
commit34e317cfd70be959f016d717de06e24e22266d13
treeb0e11ca6e14cf01aeb2e1d77ce5831e2609a3dbd
parent82494cd628eedd4c698a7f11a4001c586107c198
util: storage: Fix qcow(2) header parser according to docs

The backing store string location offset 0 determines that the file
isn't present. The string size shouldn't be then checked:

from qemu.git/docs/specs/qcow2.txt

== Header ==

The first cluster of a qcow2 image contains the file header:

Byte  0 -  3:   magic
                QCOW magic string ("QFI\xfb")

      4 -  7:   version
                Version number (valid values are 2 and 3)

      8 - 15:   backing_file_offset
                Offset into the image file at which the backing file name
                is stored (NB: The string is not null terminated). 0 if the
                image doesn't have a backing file.

     16 - 19:   backing_file_size
                Length of the backing file name in bytes. Must not be
                longer than 1023 bytes. Undefined if the image doesn't have
                a backing file.         ^^^^^^^^^

This patch intentionally leaves the backing file string size check in
place in case a malformatted file would be presented to libvirt. Also
according to the docs the string size is maximum 1023 bytes, thus this
patch adds a check to verify that.

I was also able to verify that the check was done the same way in the
legacy qcow fromat (in qemu's code).
src/util/virstoragefile.c