From: Sami Kerola Date: Thu, 30 Jun 2011 19:27:42 +0000 (+0200) Subject: isosize: check user input to be numeric X-Git-Tag: v2.20-rc1~87^2~3 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ab3a34ffc9d84f8c16cff29874e46456b26bf00a;p=thirdparty%2Futil-linux.git isosize: check user input to be numeric Signed-off-by: Sami Kerola --- diff --git a/disk-utils/Makefile.am b/disk-utils/Makefile.am index cf4a3e8053..6b937bd2bc 100644 --- a/disk-utils/Makefile.am +++ b/disk-utils/Makefile.am @@ -27,6 +27,7 @@ mkswap_SOURCES = mkswap.c $(utils_common) $(top_srcdir)/lib/wholedisk.c $(top_sr mkswap_LDADD = $(uuid_ldadd) mkswap_CFLAGS = $(AM_CFLAGS) $(uuid_cflags) +isosize_SOURCES = isosize.c $(top_srcdir)/lib/strutils.c usrbin_exec_PROGRAMS = isosize usrsbin_exec_PROGRAMS = diff --git a/disk-utils/isosize.c b/disk-utils/isosize.c index 547d450d06..a59d46d9e9 100644 --- a/disk-utils/isosize.c +++ b/disk-utils/isosize.c @@ -28,6 +28,7 @@ #include "nls.h" #include "c.h" +#include "strutils.h" #define ISODCL(from, to) (to - from + 1) @@ -117,7 +118,7 @@ struct iso_primary_descriptor { }; static void -isosize(char *filenamep, int xflag, int divisor) { +isosize(char *filenamep, int xflag, long divisor) { int fd, nsecs, ssize; struct iso_primary_descriptor ipd; @@ -168,7 +169,7 @@ static void __attribute__((__noreturn__)) usage(FILE *out) int main(int argc, char * argv[]) { int j, ct, opt, xflag = 0; - int divisor = 0; + long divisor = 0; static const struct option longopts[] = { {"divisor", no_argument, 0, 'd'}, @@ -185,7 +186,9 @@ main(int argc, char * argv[]) { while ((opt = getopt_long(argc, argv, "d:xVh", longopts, NULL)) != -1) switch (opt) { case 'd': - divisor = atoi(optarg); + divisor = + strtol_or_err(optarg, + _("invalid divisor argument")); break; case 'x': xflag = 1;