]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
blockdev: improve arguments parsing (remove atoi)
authorKarel Zak <kzak@redhat.com>
Tue, 22 Jun 2021 10:32:58 +0000 (12:32 +0200)
committerKarel Zak <kzak@redhat.com>
Tue, 22 Jun 2021 10:32:58 +0000 (12:32 +0200)
old version:
 # blockdev --setfra 4x096 /dev/sdc

new version:
 # blockdev --setfra 4x096 /dev/sdc
 blockdev: failed to parse command argument: '4x096'

Addresses: https://github.com/karelzak/util-linux/issues/1358
Signed-off-by: Karel Zak <kzak@redhat.com>
disk-utils/blockdev.c

index f425d153362a3a3208de4b0a9c6c237dfa6185bf..4fd5b8495a510e83e4ff2bd1465546ecfa22515a 100644 (file)
@@ -16,6 +16,7 @@
 #include "blkdev.h"
 #include "pathnames.h"
 #include "closestream.h"
+#include "strutils.h"
 #include "sysfs.h"
 
 struct bdc {
@@ -351,7 +352,7 @@ static void do_commands(int fd, char **argv, int d)
                                              bdcms[j].name);
                                        errtryhelp(EXIT_FAILURE);
                                }
-                               iarg = atoi(argv[++i]);
+                               iarg = strtos32_or_err(argv[++i], _("failed to parse command argument"));
                        } else
                                iarg = bdcms[j].argval;