From 64af251a33ece5dd25b079a675939c86a3801018 Mon Sep 17 00:00:00 2001 From: David Schweikert Date: Tue, 1 Nov 2016 18:08:53 +0100 Subject: [PATCH] safer -i option parsing --- ci/test-12-option-type.pl | 4 ++-- src/fping.c | 6 ++++-- 2 files changed, 6 insertions(+), 4 deletions(-) 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':