From 2fb30970adde23ad79b11a7bf3ab200528dc5f3e Mon Sep 17 00:00:00 2001 From: Matteo Cypriani Date: Fri, 11 Mar 2011 12:45:23 +0100 Subject: [PATCH] [Client] check_configuration(): check port numbers --- .../owlps-client/owlps-client.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/infrastructure-centred/owlps-client/owlps-client.c b/infrastructure-centred/owlps-client/owlps-client.c index 7bdc7de..6f6410f 100644 --- a/infrastructure-centred/owlps-client/owlps-client.c +++ b/infrastructure-centred/owlps-client/owlps-client.c @@ -227,6 +227,23 @@ void check_configuration() options.nb_pkt = DEFAULT_NBPKT_NORMAL ; } + // Check port numbers + if (options.dest_port < 1 || options.dest_port > 65535) + { +#ifdef DEBUG + fprintf(stderr, "Warning! Bad dest_port:" + " failing back to default value.\n") ; + options.dest_port = LOC_REQUEST_DEFAULT_PORT ; +#endif // DEBUG + } + if (options.listening_port > 65535) + { +#ifdef DEBUG + fprintf(stderr, "Warning! listening_port too high: ignored.\n") ; + options.listening_port = 0 ; +#endif // DEBUG + } + // We want to send a calibration request AND to be located, which is // not allowed: if (is_calibration_request && options.listening_port > 0)