cryptospore / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone
34b321
From 362faad8e8f4c2c2c875df12f6bbae7964c0146d Mon Sep 17 00:00:00 2001
34b321
From: John Snow <jsnow@redhat.com>
34b321
Date: Mon, 23 Nov 2015 17:38:38 +0100
34b321
Subject: [PATCH 19/27] qemu-io: Check for trailing chars
34b321
34b321
RH-Author: John Snow <jsnow@redhat.com>
34b321
Message-id: <1448300320-7772-20-git-send-email-jsnow@redhat.com>
34b321
Patchwork-id: 68449
34b321
O-Subject: [RHEL-7.3 qemu-kvm PATCH v2 19/21] qemu-io: Check for trailing chars
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
Make sure there's not trailing garbage, e.g.
34b321
"64k-whatever-i-want-here"
34b321
34b321
Reported-by: Max Reitz <mreitz@redhat.com>
34b321
Signed-off-by: John Snow <jsnow@redhat.com>
34b321
Reviewed-by: Eric Blake <eblake@redhat.com>
34b321
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
34b321
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
34b321
(cherry picked from commit ef5a788527b2038d742b057a415ab4d0e735e98f)
34b321
Signed-off-by: John Snow <jsnow@redhat.com>
34b321
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
34b321
34b321
Conflicts:
34b321
  qemu-io-cmds.c:
34b321
    - Downstream still uses strtosz_suffix, not
34b321
      qemu_strtosz_suffix.
34b321
34b321
Signed-off-by: John Snow <jsnow@redhat.com>
34b321
---
34b321
 qemu-io-cmds.c | 9 ++++++++-
34b321
 1 file changed, 8 insertions(+), 1 deletion(-)
34b321
34b321
diff --git a/qemu-io-cmds.c b/qemu-io-cmds.c
34b321
index 95345fe..6ea027d 100644
34b321
--- a/qemu-io-cmds.c
34b321
+++ b/qemu-io-cmds.c
34b321
@@ -124,7 +124,14 @@ static char **breakline(char *input, int *count)
34b321
 static int64_t cvtnum(const char *s)
34b321
 {
34b321
     char *end;
34b321
-    return strtosz_suffix(s, &end, STRTOSZ_DEFSUFFIX_B);
34b321
+    int64_t ret;
34b321
+
34b321
+    ret = strtosz_suffix(s, &end, STRTOSZ_DEFSUFFIX_B);
34b321
+    if (*end != '\0') {
34b321
+        /* Detritus at the end of the string */
34b321
+        return -EINVAL;
34b321
+    }
34b321
+    return ret;
34b321
 }
34b321
 
34b321
 #define EXABYTES(x)     ((long long)(x) << 60)
34b321
-- 
34b321
1.8.3.1
34b321