From: David Schweikert Date: Tue, 1 Nov 2016 17:08:53 +0000 (+0100) Subject: safer -i option parsing X-Git-Url: https://git.gsnw.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=64af251a33ece5dd25b079a675939c86a3801018;p=fping.git safer -i option parsing --- diff --git a/ci/test-12-option-type.pl b/ci/test-12-option-type.pl index c6a88c5..c1ab582 100755 --- a/ci/test-12-option-type.pl +++ b/ci/test-12-option-type.pl @@ -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 i O p Q r t)) { my $cmd = Test::Command->new(cmd => "fping -$arg xxx"); $cmd->exit_is_num(1); $cmd->stdout_is_eq(""); diff --git a/src/fping.c b/src/fping.c index 47c17fe..cc5d715 100644 --- a/src/fping.c +++ b/src/fping.c @@ -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':