From 0e7508ba4366a6f4e6b2f0ac5cc520a2f37fb7d6 Mon Sep 17 00:00:00 2001 From: Benjamin Franzke Date: Fri, 9 Nov 2012 09:50:50 +0100 Subject: pd_server: Check rounds parameter to be a number --- pd_server.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pd_server.c b/pd_server.c index 829a6f7..7c5a01f 100644 --- a/pd_server.c +++ b/pd_server.c @@ -35,14 +35,14 @@ main(int argc, char *argv[]) int port = 8068; int a_payment = 0, b_payment = 0, rounds, i; int optval = 1; + char *endptr; - if (argc < 2) { + errno = 0; + if (argc < 2 || (rounds = strtol(argv[1], NULL, 10)) <= 0 || errno!=0) { fprintf(stderr, "usage: %s number-of-rounds\n", argv[0]); exit(EXIT_FAILURE); } - rounds = atoi(argv[1]); - sock = socket(AF_INET, SOCK_STREAM, 0); if (sock < 0) return EXIT_FAILURE; -- cgit