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