Skip to content

Commit 3a24037

Browse files
committed
Require 'options' to -s* and -P* to be joined to them, e.g. not '-s SUV'
1 parent ebf083c commit 3a24037

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

nmap.cc

+13-3
Original file line numberDiff line numberDiff line change
@@ -683,7 +683,7 @@ void parse_options(int argc, char **argv) {
683683

684684
/* OK, lets parse these args! */
685685
optind = 1; /* so it can be called multiple times */
686-
while ((arg = getopt_long_only(argc, argv, "46Ab:D:d::e:Ffg:hIi:M:m:nO::o:P:p:qRrS:s:T:Vv::", long_options, &option_index)) != EOF) {
686+
while ((arg = getopt_long_only(argc, argv, "46Ab:D:d::e:Ffg:hIi:M:m:nO::o:P::p:qRrS:s::T:Vv::", long_options, &option_index)) != EOF) {
687687
switch (arg) {
688688
case 0:
689689
#ifndef NOLUA
@@ -1145,8 +1145,18 @@ void parse_options(int argc, char **argv) {
11451145
delayed_options.normalfilename = logfilename(optarg, local_time);
11461146
break;
11471147
case 'P':
1148-
if (*optarg == '\0' || *optarg == 'I' || *optarg == 'E')
1148+
if (!optarg) {
1149+
delayed_options.warn_deprecated("P", "PE");
1150+
o.pingtype |= PINGTYPE_ICMP_PING;
1151+
}
1152+
else if (*optarg == '\0' || *optarg == 'I' || *optarg == 'E') {
1153+
if (*optarg != 'E') {
1154+
char buf[4];
1155+
Snprintf(buf, 3, "P%c", *optarg);
1156+
delayed_options.warn_deprecated(buf, "PE");
1157+
}
11491158
o.pingtype |= PINGTYPE_ICMP_PING;
1159+
}
11501160
else if (*optarg == 'M')
11511161
o.pingtype |= PINGTYPE_ICMP_MASK;
11521162
else if (*optarg == 'P')
@@ -1259,7 +1269,7 @@ void parse_options(int argc, char **argv) {
12591269
o.spoofsource = true;
12601270
break;
12611271
case 's':
1262-
if (!*optarg) {
1272+
if (!optarg || !*optarg) {
12631273
printusage();
12641274
error("An option is required for -s, most common are -sT (tcp scan), -sS (SYN scan), -sF (FIN scan), -sU (UDP scan) and -sn (Ping scan)");
12651275
exit(-1);

0 commit comments

Comments
 (0)