]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
isosize: check user input to be numeric
authorSami Kerola <kerolasa@iki.fi>
Thu, 30 Jun 2011 19:27:42 +0000 (21:27 +0200)
committerSami Kerola <kerolasa@iki.fi>
Thu, 30 Jun 2011 20:02:10 +0000 (22:02 +0200)
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
disk-utils/Makefile.am
disk-utils/isosize.c

index cf4a3e8053f73a14170e55e00a61e597ceca25d5..6b937bd2bc0a33685e3c4763bb961be00ea050e9 100644 (file)
@@ -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 =
 
index 547d450d06681394f60ebdad4b90ab4758181b36..a59d46d9e98682dfbcf6c6b1d491a13892854f9a 100644 (file)
@@ -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;