]> git.proxmox.com Git - mirror_qemu.git/commit
qcow2: Generalize validate_table_offset() into qcow2_validate_table()
authorAlberto Garcia <berto@igalia.com>
Tue, 6 Mar 2018 16:14:06 +0000 (18:14 +0200)
committerKevin Wolf <kwolf@redhat.com>
Fri, 9 Mar 2018 14:17:47 +0000 (15:17 +0100)
commit0cf0e5980bb95a914a40ba0eb8e69c3d75c513fb
tree6be0b11d7bf1365030d222d6532fbc1584304870
parent2fd6163884d74e74dd1ef54ab229d15c61d0b4cb
qcow2: Generalize validate_table_offset() into qcow2_validate_table()

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>
block/qcow2.c
block/qcow2.h
tests/qemu-iotests/080.out