Skip to content

Commit

Permalink
Error if argument to --timeout is in unexpected format
Browse files Browse the repository at this point in the history
  • Loading branch information
jetmore committed Nov 11, 2019
1 parent 2ae8953 commit 15b6905
Show file tree
Hide file tree
Showing 11 changed files with 11 additions and 55 deletions.
3 changes: 3 additions & 0 deletions Changes
Original file line number Diff line number Diff line change
Expand Up @@ -890,3 +890,6 @@
after each stage of option processing and error if so.
* 20191111 Rework the command line reconstruction so that options that
don't take an argument do not include one in the reconstuction.
* 20191111 Unexpected argument format for --timeout now errors and exits
instead of silently using default timeout.
* 20191111 Document that --timeout argument can use 'h' as a modifier.
2 changes: 1 addition & 1 deletion doc/base.pod
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ This option is similar to --drop-after, but instead of dropping the connection a

=item --timeout [time]

Use argument as the SMTP transaction timeout, or prompt user if no argument given. Argument can either be a pure digit, which will be interpreted as seconds, or can have a specifier s or m (5s = 5 seconds, 3m = 180 seconds). As a special case, 0 means don't timeout the transactions. Default value is 30s.
Use argument as the SMTP transaction timeout, or prompt user if no argument given. Argument can either be a pure digit, which will be interpreted as seconds, or can have a specifier s, m, or h (5s = 5 seconds, 3m = 180 seconds, 1h = 3600 seconds). As a special case, 0 means don't timeout the transactions. Default value is 30s.

=item --protocol [protocol]

Expand Down
5 changes: 3 additions & 2 deletions swaks
Original file line number Diff line number Diff line change
Expand Up @@ -1611,8 +1611,9 @@ sub test_support {
sub time_to_seconds {
my $t = shift;

if ($t !~ /^(\d+)([hms])?/i) {
return(30); # error condition - just use default value
if ($t !~ /^(\d+)([hms])?$/i) {
ptrans(12, 'Unknown timeout format \'' . $t . '\'');
exit(1);
} else {
my $r = $1;
my $u = lc($2);
Expand Down
1 change: 1 addition & 0 deletions testing/regressions/_options-protocol/out-ref/00552.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*** Unknown timeout format 'tuesday'
13 changes: 0 additions & 13 deletions testing/regressions/_options-protocol/out-ref/00552.stdout
Original file line number Diff line number Diff line change
@@ -1,13 +0,0 @@
Protocol Info:
protocol = esmtp
helo = helo-string
from = [email protected]
to = [email protected]
force getpwuid = FALSE
quit after =
drop after =
drop after send =
server_only = FALSE
timeout = 30
pipeline = FALSE
prdr = FALSE
1 change: 1 addition & 0 deletions testing/regressions/_options-protocol/out-ref/00562.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*** Unknown timeout format 'tuesday'
13 changes: 0 additions & 13 deletions testing/regressions/_options-protocol/out-ref/00562.stdout
Original file line number Diff line number Diff line change
@@ -1,13 +0,0 @@
Protocol Info:
protocol = esmtp
helo = helo-string
from = [email protected]
to = [email protected]
force getpwuid = FALSE
quit after =
drop after =
drop after send =
server_only = FALSE
timeout = 30
pipeline = FALSE
prdr = FALSE
1 change: 1 addition & 0 deletions testing/regressions/_options-protocol/out-ref/00572.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*** Unknown timeout format 'tuesday'
13 changes: 0 additions & 13 deletions testing/regressions/_options-protocol/out-ref/00572.stdout
Original file line number Diff line number Diff line change
@@ -1,13 +0,0 @@
Protocol Info:
protocol = esmtp
helo = helo-string
from = [email protected]
to = [email protected]
force getpwuid = FALSE
quit after =
drop after =
drop after send =
server_only = FALSE
timeout = 30
pipeline = FALSE
prdr = FALSE
1 change: 1 addition & 0 deletions testing/regressions/_options-protocol/out-ref/05509.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*** Unknown timeout format '2g'
13 changes: 0 additions & 13 deletions testing/regressions/_options-protocol/out-ref/05509.stdout
Original file line number Diff line number Diff line change
@@ -1,13 +0,0 @@
Protocol Info:
protocol = esmtp
helo = hstring
from = [email protected]
to = [email protected]
force getpwuid = FALSE
quit after =
drop after =
drop after send =
server_only = FALSE
timeout = 2
pipeline = FALSE
prdr = FALSE

0 comments on commit 15b6905

Please sign in to comment.