thebeanogamer / rpms / qemu-kvm

Forked from rpms/qemu-kvm 5 months ago
Clone
5d360b
From 8fde4e2c8a03832087c7e006e35988245f55c57b Mon Sep 17 00:00:00 2001
5d360b
From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= <marcandre.lureau@redhat.com>
5d360b
Date: Fri, 3 Nov 2017 18:06:12 +0100
5d360b
Subject: [PATCH 2/2] qemu-option: reject empty number value
5d360b
MIME-Version: 1.0
5d360b
Content-Type: text/plain; charset=UTF-8
5d360b
Content-Transfer-Encoding: 8bit
5d360b
5d360b
RH-Author: Marc-André Lureau <marcandre.lureau@redhat.com>
5d360b
Message-id: <20171103180612.24523-1-marcandre.lureau@redhat.com>
5d360b
Patchwork-id: 77500
5d360b
O-Subject: [RHEL-7.5 qemu-kvm PATCH v2] qemu-option: reject empty number value
5d360b
Bugzilla: 1417864
5d360b
RH-Acked-by: Gerd Hoffmann <kraxel@redhat.com>
5d360b
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
5d360b
RH-Acked-by: Laurent Vivier <lvivier@redhat.com>
5d360b
RH-Acked-by: Laszlo Ersek <lersek@redhat.com>
5d360b
5d360b
(Upstream commit to fix this bug is
5d360b
3403e5eb884f3a74c40fe7cccc103f848c040215, however, the patch relies on
5d360b
qemu_strtou64() which was introduced later and had several iterations)
5d360b
5d360b
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
5d360b
---
5d360b
v2:
5d360b
- add errno check (Laszlo Ersek)
5d360b
5d360b
util/qemu-option.c | 3 ++-
5d360b
 1 file changed, 2 insertions(+), 1 deletion(-)
5d360b
5d360b
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
5d360b
---
5d360b
 util/qemu-option.c | 3 ++-
5d360b
 1 file changed, 2 insertions(+), 1 deletion(-)
5d360b
5d360b
diff --git a/util/qemu-option.c b/util/qemu-option.c
5d360b
index 4de5d13..5a85abd 100644
5d360b
--- a/util/qemu-option.c
5d360b
+++ b/util/qemu-option.c
5d360b
@@ -162,8 +162,9 @@ static void parse_option_number(const char *name, const char *value,
5d360b
     uint64_t number;
5d360b
 
5d360b
     if (value != NULL) {
5d360b
+        errno = 0;
5d360b
         number = strtoull(value, &postfix, 0);
5d360b
-        if (*postfix != '\0') {
5d360b
+        if (errno != 0 || *postfix != '\0' || postfix == value) {
5d360b
             error_set(errp, QERR_INVALID_PARAMETER_VALUE, name, "a number");
5d360b
             return;
5d360b
         }
5d360b
-- 
5d360b
1.8.3.1
5d360b