diff options
author | Kevin Wolf <kwolf@redhat.com> | 2018-03-05 17:39:31 +0100 |
---|---|---|
committer | Kevin Wolf <kwolf@redhat.com> | 2018-03-19 12:01:24 +0100 |
commit | e39e959e89b33bc0e17a702db42ea8a5f3763133 (patch) | |
tree | ea094c29624392293206da065ebe7756d34dd615 /block | |
parent | 1bedcaf120c128e9f565185171d378f8846d1567 (diff) |
luks: Turn invalid assertion into check
The .bdrv_getlength implementation of the crypto block driver asserted
that the payload offset isn't after EOF. This is an invalid assertion to
make as the image file could be corrupted. Instead, check it and return
-EIO if the file is too small for the payload offset.
Zero length images are fine, so trigger -EIO only on offset > len, not
on offset >= len as the assertion did before.
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Diffstat (limited to 'block')
-rw-r--r-- | block/crypto.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/block/crypto.c b/block/crypto.c index a1139b6f09..00fb40c631 100644 --- a/block/crypto.c +++ b/block/crypto.c @@ -518,7 +518,10 @@ static int64_t block_crypto_getlength(BlockDriverState *bs) uint64_t offset = qcrypto_block_get_payload_offset(crypto->block); assert(offset < INT64_MAX); - assert(offset < len); + + if (offset > len) { + return -EIO; + } len -= offset; |