diff --git a/owlps-client/owlps-client.c b/owlps-client/owlps-client.c index f9d7c2e..1a0aef1 100644 --- a/owlps-client/owlps-client.c +++ b/owlps-client/owlps-client.c @@ -134,9 +134,12 @@ void parse_main_options(int argc, char **argv) strncpy(options.iface, optarg, IFNAMSIZ + 1) ; break ; case 'l' : - /* Facultative getopt options does not handle separated - * values (like -l ) */ - if (optarg == 0) + /* Facultative getopt options do not handle separated values + * (like -l ), so we have to test separately. + */ + if (optarg) // We got an option like -l, it's OK + options.listening_port = strtoul(optarg, NULL, 0) ; + else // We got -l alone or -l { /* If we are at the end of the string, or the next optind * is an option, we have -l without a port number */ @@ -151,8 +154,6 @@ void parse_main_options(int argc, char **argv) optind++ ; } } - else // We got an option like -l, it's OK - options.listening_port = strtoul(optarg, NULL, 0) ; break ; case 'n' : options.nb_pkt = strtoul(optarg, NULL, 0) ;