summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhil Pennock <pdp@exim.org>2012-05-17 22:12:59 -0400
committerPhil Pennock <pdp@exim.org>2012-05-17 22:12:59 -0400
commit1ec3f27dbd09d889f2839d3c24a095dc4efa49ac (patch)
treee4586b5ad33786d03b8ee482b7bae3a109b8e23d
parent5c8cda3a8089ff340224e6ab147d4bbe18dca0e2 (diff)
Make test-suite client cmd -t<timeout> actually work
-rw-r--r--test/src/client.c28
1 files changed, 24 insertions, 4 deletions
diff --git a/test/src/client.c b/test/src/client.c
index d9ad8139f..58ab56d4c 100644
--- a/test/src/client.c
+++ b/test/src/client.c
@@ -378,12 +378,14 @@ char *interface = NULL;
char *address = NULL;
char *certfile = NULL;
char *keyfile = NULL;
+char *end = NULL;
int argi = 1;
int host_af, port, s_len, rc, sock, save_errno;
int timeout = 1;
int tls_active = 0;
int sent_starttls = 0;
int tls_on_connect = 0;
+long tmplong;
#if HAVE_IPV6
struct sockaddr_in6 s_in6;
@@ -418,12 +420,30 @@ while (argc >= argi + 1 && argv[argi][0] == '-')
}
else if (argv[argi][1] == 't' && isdigit(argv[argi][2]))
{
- timeout = atoi(argv[argi]+1);
+ tmplong = strtol(argv[argi]+2, &end, 10);
+ if (end == argv[argi]+2 || *end)
+ {
+ fprintf(stderr, "Failed to parse seconds from option <%s>\n",
+ argv[argi]);
+ exit(1);
+ }
+ if (tmplong > 10000L)
+ {
+ fprintf(stderr, "Unreasonably long wait of %d seconds requested\n",
+ tmplong);
+ exit(1);
+ }
+ if (tmplong < 0L)
+ {
+ fprintf(stderr, "Timeout must not be negative (%d)\n", tmplong);
+ exit(1);
+ }
+ timeout = (int) tmplong;
argi++;
}
else
{
- printf("Unrecognized option %s\n", argv[argi]);
+ fprintf(stderr, "Unrecognized option %s\n", argv[argi]);
exit(1);
}
}
@@ -432,7 +452,7 @@ while (argc >= argi + 1 && argv[argi][0] == '-')
if (argc < argi+1)
{
- printf("No IP address given\n");
+ fprintf(stderr, "No IP address given\n");
exit(1);
}
@@ -443,7 +463,7 @@ host_af = (strchr(address, ':') != NULL)? AF_INET6 : AF_INET;
if (argc < argi+1)
{
- printf("No port number given\n");
+ fprintf(stderr, "No port number given\n");
exit(1);
}