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 <kzak@redhat.com>
This commit is contained in:
Karel Zak 2021-06-22 12:32:58 +02:00
parent 22cecf786f
commit cbfbbc44c4
1 changed files with 2 additions and 1 deletions

View 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;