]> git.gsnw.org Git - fping.git/commitdiff
safer -i option parsing
authorDavid Schweikert <david@schweikert.ch>
Tue, 1 Nov 2016 17:08:53 +0000 (18:08 +0100)
committerDavid Schweikert <david@schweikert.ch>
Tue, 1 Nov 2016 17:08:53 +0000 (18:08 +0100)
ci/test-12-option-type.pl
src/fping.c

index c6a88c5a8a2c755eac5262b14848fa4220371640..c1ab5824abd00629b445deba2c7159bf6e44b571 100755 (executable)
@@ -1,8 +1,8 @@
 #!/usr/bin/perl -w
 
-use Test::Command tests => 30;
+use Test::Command tests => 33;
 
-for my $arg (qw(b B c C H O p Q r t)) {
+for my $arg (qw(b B c C H O p Q r t)) {
     my $cmd = Test::Command->new(cmd => "fping -$arg xxx");
     $cmd->exit_is_num(1);
     $cmd->stdout_is_eq("");
index 47c17fef91856596fe9694c7bb485d0dfcf01a3d..cc5d7159aa30e077be3986c93fc8dcef041a9e6f 100644 (file)
@@ -400,12 +400,14 @@ int main( int argc, char **argv )
             break;
         
         case 'r':
-            if (!sscanf(optarg,"%i",&retry))
+            if (!sscanf(optarg,"%u",&retry))
                 usage(1);
             break;
         
         case 'i':
-            interval = ( unsigned int )atoi( optarg ) * 100;
+            if (!sscanf(optarg,"%u",&interval))
+                usage(1);
+            interval *= 100;
             break;
 
         case 'p':