From 6f894ee6940abe9e82531226704b5ce22429a10d Mon Sep 17 00:00:00 2001 From: Ralf Baechle Date: Wed, 10 Jun 2015 23:09:57 +0200 Subject: Call: Fix parsing of the argument of the -T option. Signed-off-by: Ralf Baechle --- call/call.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) (limited to 'call/call.c') diff --git a/call/call.c b/call/call.c index a1cf51c..b0cf956 100644 --- a/call/call.c +++ b/call/call.c @@ -19,6 +19,7 @@ #include #include +#include #include #include #include @@ -2352,15 +2353,17 @@ int main(int argc, char **argv) case 'S': be_silent = 1; break; - case 'T': - { double f = atof(optarg); - inactivity_timeout.tv_sec = ((time_t) f) & 0x7fffffff; - inactivity_timeout.tv_usec = (time_t ) (f - (double ) (time_t ) f); - if (f < 0.001 || f > (double) (0x7fffffff) || (inactivity_timeout.tv_sec == 0 && inactivity_timeout.tv_usec == 0)) { - fprintf(stderr, "call: option '-T' must be > 0.001 (1ms) and < 69 years\n"); - return 1; - } - inactivity_timeout_is_set = TRUE; + case 'T': { + double f = atof(optarg); + + inactivity_timeout.tv_sec = f; + inactivity_timeout.tv_usec = (f - (long) f) * 1000000; + + if (f < 0.001 || f > (double) LONG_MAX) { + fprintf(stderr, "call: option '-T' must be > 0.001 (1ms) and < %ld seconds\n", LONG_MAX); + return 1; + } + inactivity_timeout_is_set = TRUE; } break; case 't': -- cgit v1.2.3