summary refs log tree commit diff stats
path: root/qemu-io-cmds.c
diff options
context:
space:
mode:
Diffstat (limited to 'qemu-io-cmds.c')
-rw-r--r--qemu-io-cmds.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/qemu-io-cmds.c b/qemu-io-cmds.c
index e415b03cd0..7ac1576d4c 100644
--- a/qemu-io-cmds.c
+++ b/qemu-io-cmds.c
@@ -137,15 +137,17 @@ static char **breakline(char *input, int *count)
 
 static int64_t cvtnum(const char *s)
 {
-    char *end;
-    int64_t ret;
+    int err;
+    uint64_t value;
 
-    ret = qemu_strtosz_suffix(s, &end, QEMU_STRTOSZ_DEFSUFFIX_B);
-    if (*end != '\0') {
-        /* Detritus at the end of the string */
-        return -EINVAL;
+    err = qemu_strtosz(s, NULL, &value);
+    if (err < 0) {
+        return err;
     }
-    return ret;
+    if (value > INT64_MAX) {
+        return -ERANGE;
+    }
+    return value;
 }
 
 static void print_cvtnum_err(int64_t rc, const char *arg)