thebeanogamer / rpms / qemu-kvm

Forked from rpms/qemu-kvm 5 months ago
Clone
34b321
From 862f45e0ad5a70d10bffa435d5331c444874e4d2 Mon Sep 17 00:00:00 2001
34b321
From: John Snow <jsnow@redhat.com>
34b321
Date: Mon, 23 Nov 2015 17:38:23 +0100
34b321
Subject: [PATCH 04/27] qemu-io: Handle cvtnum() errors in 'alloc'
34b321
34b321
RH-Author: John Snow <jsnow@redhat.com>
34b321
Message-id: <1448300320-7772-5-git-send-email-jsnow@redhat.com>
34b321
Patchwork-id: 68431
34b321
O-Subject: [RHEL-7.3 qemu-kvm PATCH v2 04/21] qemu-io: Handle cvtnum() errors in 'alloc'
34b321
Bugzilla: 1272523
34b321
RH-Acked-by: Thomas Huth <thuth@redhat.com>
34b321
RH-Acked-by: Laszlo Ersek <lersek@redhat.com>
34b321
RH-Acked-by: Max Reitz <mreitz@redhat.com>
34b321
34b321
From: Kevin Wolf <kwolf@redhat.com>
34b321
34b321
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
34b321
Reviewed-by: Eric Blake <eblake@redhat.com>
34b321
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
34b321
(cherry picked from commit cf49a6a00c19cabf4006d4f82bef26345043e7b5)
34b321
Signed-off-by: John Snow <jsnow@redhat.com>
34b321
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
34b321
---
34b321
 qemu-io.c | 9 ++++++++-
34b321
 1 file changed, 8 insertions(+), 1 deletion(-)
34b321
34b321
diff --git a/qemu-io.c b/qemu-io.c
34b321
index 3b5890e..e4fa2fc 100644
34b321
--- a/qemu-io.c
34b321
+++ b/qemu-io.c
34b321
@@ -1608,7 +1608,10 @@ static int alloc_f(int argc, char **argv)
34b321
     int ret;
34b321
 
34b321
     offset = cvtnum(argv[1]);
34b321
-    if (offset & 0x1ff) {
34b321
+    if (offset < 0) {
34b321
+        printf("non-numeric offset argument -- %s\n", argv[1]);
34b321
+        return 0;
34b321
+    } else if (offset & 0x1ff) {
34b321
         printf("offset %" PRId64 " is not sector aligned\n",
34b321
                offset);
34b321
         return 0;
34b321
@@ -1616,6 +1619,10 @@ static int alloc_f(int argc, char **argv)
34b321
 
34b321
     if (argc == 3) {
34b321
         nb_sectors = cvtnum(argv[2]);
34b321
+        if (nb_sectors < 0) {
34b321
+            printf("non-numeric length argument -- %s\n", argv[2]);
34b321
+            return 0;
34b321
+        }
34b321
     } else {
34b321
         nb_sectors = 1;
34b321
     }
34b321
-- 
34b321
1.8.3.1
34b321