[Client] check_configuration(): check port numbers

This commit is contained in:
Matteo Cypriani 2011-03-11 12:45:23 +01:00
parent b88f26e503
commit 2fb30970ad
1 changed files with 17 additions and 0 deletions

View File

@ -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)