mirror of
https://github.com/nmap/nmap.git
synced 2025-12-06 04:31:29 +00:00
Allow doing --data-length 0. That's the documented way to turn off UDP
payloads.
This commit is contained in:
4
nmap.cc
4
nmap.cc
@@ -899,11 +899,11 @@ int nmap_main(int argc, char *argv[]) {
|
||||
o.debugging++;
|
||||
} else if (optcmp(long_options[option_index].name, "data-length") == 0) {
|
||||
o.extra_payload_length = (int)strtol(optarg, NULL, 10);
|
||||
if (o.extra_payload_length < 1 || o.extra_payload_length > MAX_PAYLOAD_ALLOWED)
|
||||
if (o.extra_payload_length < 0 || o.extra_payload_length > MAX_PAYLOAD_ALLOWED)
|
||||
fatal("data-length must be between 0 and %d", MAX_PAYLOAD_ALLOWED);
|
||||
if (o.extra_payload_length > 1400 ) /* 1500 - IP with opts - TCP with opts. */
|
||||
error("WARNING: Payloads bigger than 1400 bytes may not be sent successfully.");
|
||||
o.extra_payload = (char *) safe_malloc(o.extra_payload_length);
|
||||
o.extra_payload = (char *) safe_malloc(MIN(o.extra_payload_length, 1));
|
||||
get_random_bytes(o.extra_payload, o.extra_payload_length);
|
||||
} else if (optcmp(long_options[option_index].name, "send-eth") == 0) {
|
||||
o.sendpref = PACKET_SEND_ETH_STRONG;
|
||||
|
||||
@@ -227,15 +227,14 @@ static const char payload_null[] = "";
|
||||
length is returned through the length pointer. */
|
||||
const char *get_udp_payload(u16 dport, size_t *length) {
|
||||
|
||||
if (o.extra_payload_length > 0) {
|
||||
if (o.extra_payload != NULL) {
|
||||
*length = o.extra_payload_length;
|
||||
return o.extra_payload;
|
||||
}
|
||||
else
|
||||
} else {
|
||||
return udp_port2payload(dport, length);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Get a payload appropriate for the given UDP port. For certain selected ports
|
||||
a payload is returned, and for others a zero-length payload is returned. The
|
||||
length is returned through the length pointer. */
|
||||
|
||||
Reference in New Issue
Block a user