0cf0e5980b
This function checks that the offset and size of a table are valid. While the offset checks are fine, the size check is too generic, since it only verifies that the total size in bytes fits in a 64-bit integer. In practice all tables used in qcow2 have much smaller size limits, so the size needs to be checked again for each table using its actual limit. This patch generalizes this function by allowing the caller to specify the maximum size for that table. In addition to that it allows passing an Error variable. The function is also renamed and made public since we're going to use it in other parts of the code. Signed-off-by: Alberto Garcia <berto@igalia.com> Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
68 lines
2.9 KiB
Plaintext
68 lines
2.9 KiB
Plaintext
QA output created by 080
|
|
|
|
== Huge header size ==
|
|
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864
|
|
can't open device TEST_DIR/t.qcow2: qcow2 header exceeds cluster size
|
|
can't open device TEST_DIR/t.qcow2: qcow2 header exceeds cluster size
|
|
|
|
== Huge unknown header extension ==
|
|
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864
|
|
can't open device TEST_DIR/t.qcow2: Invalid backing file offset
|
|
can't open device TEST_DIR/t.qcow2: Header extension too large
|
|
can't open device TEST_DIR/t.qcow2: Header extension too large
|
|
|
|
== Huge refcount table size ==
|
|
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864
|
|
can't open device TEST_DIR/t.qcow2: Reference count table too large
|
|
can't open device TEST_DIR/t.qcow2: Reference count table too large
|
|
|
|
== Misaligned refcount table ==
|
|
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864
|
|
can't open device TEST_DIR/t.qcow2: Reference count table offset invalid
|
|
|
|
== Huge refcount offset ==
|
|
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864
|
|
can't open device TEST_DIR/t.qcow2: Reference count table offset invalid
|
|
|
|
== Invalid snapshot table ==
|
|
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864
|
|
can't open device TEST_DIR/t.qcow2: Snapshot table too large
|
|
can't open device TEST_DIR/t.qcow2: Snapshot table too large
|
|
can't open device TEST_DIR/t.qcow2: Snapshot table offset invalid
|
|
can't open device TEST_DIR/t.qcow2: Snapshot table offset invalid
|
|
|
|
== Hitting snapshot table size limit ==
|
|
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864
|
|
qemu-img: Could not create snapshot 'test': -27 (File too large)
|
|
read 512/512 bytes at offset 0
|
|
512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
|
|
|
|
== Invalid L1 table ==
|
|
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864
|
|
can't open device TEST_DIR/t.qcow2: Active L1 table too large
|
|
can't open device TEST_DIR/t.qcow2: Active L1 table too large
|
|
can't open device TEST_DIR/t.qcow2: Active L1 table offset invalid
|
|
can't open device TEST_DIR/t.qcow2: Active L1 table offset invalid
|
|
|
|
== Invalid L1 table (with internal snapshot in the image) ==
|
|
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864
|
|
qemu-img: Could not open 'TEST_DIR/t.IMGFMT': L1 table is too small
|
|
|
|
== Invalid backing file size ==
|
|
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864
|
|
can't open device TEST_DIR/t.qcow2: Backing file name too long
|
|
|
|
== Invalid L2 entry (huge physical offset) ==
|
|
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864
|
|
wrote 512/512 bytes at offset 0
|
|
512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
|
|
qemu-img: Could not create snapshot 'test': -27 (File too large)
|
|
qemu-img: Could not create snapshot 'test': -11 (Resource temporarily unavailable)
|
|
|
|
== Invalid snapshot L1 table ==
|
|
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864
|
|
wrote 512/512 bytes at offset 0
|
|
512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
|
|
qemu-img: Failed to load snapshot: Snapshot L1 table too large
|
|
*** done
|