]> Git Repo - qemu.git/commitdiff
luks: Turn invalid assertion into check
authorKevin Wolf <[email protected]>
Mon, 5 Mar 2018 16:39:31 +0000 (17:39 +0100)
committerKevin Wolf <[email protected]>
Mon, 19 Mar 2018 11:01:24 +0000 (12:01 +0100)
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 <[email protected]>
Reviewed-by: Daniel P. BerrangĂ© <[email protected]>
block/crypto.c

index a1139b6f096b934754aac125f01941091b5bba69..00fb40c631445b221cb205eae4fc9886f2d80888 100644 (file)
@@ -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;
 
This page took 0.025245 seconds and 4 git commands to generate.