diff mbox

[RFC,54/56] qemu-img: blk_getlength() can fail, fix img_map() to check

Message ID 1502117160-24655-55-git-send-email-armbru@redhat.com
State New
Headers show

Commit Message

Markus Armbruster Aug. 7, 2017, 2:45 p.m. UTC
Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 qemu-img.c | 4 ++++
 1 file changed, 4 insertions(+)
diff mbox

Patch

diff --git a/qemu-img.c b/qemu-img.c
index 3ae5fe3..cf3ef3e 100644
--- a/qemu-img.c
+++ b/qemu-img.c
@@ -2838,6 +2838,10 @@  static int img_map(int argc, char **argv)
     }
 
     length = blk_getlength(blk);
+    if (length < 0) {
+        error_report("Couldn't get length of image '%s': %s",
+                     filename, strerror(-length));
+    }
     while (curr.start + curr.length < length) {
         int64_t nsectors_left;
         int64_t sector_num;