From: Karel Zak Date: Tue, 22 Jun 2021 10:32:58 +0000 (+0200) Subject: blockdev: improve arguments parsing (remove atoi) X-Git-Tag: v2.37.1~46 X-Git-Url: http://git.ipfire.org/gitweb/gitweb.cgi?a=commitdiff_plain;h=cbfbbc44c4262c1f588c69e53f6dde5424e3273b;p=thirdparty%2Futil-linux.git blockdev: improve arguments parsing (remove atoi) 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 --- diff --git a/disk-utils/blockdev.c b/disk-utils/blockdev.c index f425d15336..4fd5b8495a 100644 --- a/disk-utils/blockdev.c +++ b/disk-utils/blockdev.c @@ -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;