From 717d9460074a0fd3d5423bd82745713d5b35c5fb Mon Sep 17 00:00:00 2001 From: Juliusz Chroboczek Date: Sun, 20 Nov 2011 23:47:20 +0100 Subject: [PATCH] Fix incorrect parsing of port number. --- dht-bootstrap.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/dht-bootstrap.c b/dht-bootstrap.c index d96b0f7..a282b78 100644 --- a/dht-bootstrap.c +++ b/dht-bootstrap.c @@ -406,6 +406,15 @@ main(int argc, char **argv) } } + i = optind; + + if(argc < i + 1) + goto usage; + + port = atoi(argv[i++]); + if(port <= 0 || port >= 0x10000) + goto usage; + if(ipv4) { dht_socket = socket(PF_INET, SOCK_DGRAM, 0); if(dht_socket < 0) @@ -514,15 +523,6 @@ main(int argc, char **argv) if(!quiet) dht_debug = stdout; - i = optind; - - if(argc < i + 1) - goto usage; - - port = atoi(argv[i++]); - if(port <= 0 || port >= 0x10000) - goto usage; - while(i < argc) { struct addrinfo hints, *info, *infop; memset(&hints, 0, sizeof(hints)); -- 2.44.0