1
0
mirror of https://github.com/nmap/nmap.git synced 2026-02-01 11:09:07 +00:00

Avoid portlist lookup when port is already available

This commit is contained in:
dmiller
2024-02-26 23:10:51 +00:00
parent 1a4d41a6b7
commit e75a253d72
2 changed files with 6 additions and 1 deletions

View File

@@ -500,7 +500,7 @@ void PortList::setPortState(u16 portno, u8 protocol, int state) {
state_counts_proto[proto][state]++;
if(state == PORT_FILTERED || state == PORT_OPENFILTERED)
setStateReason(portno, protocol, ER_NORESPONSE, 0, NULL);
setStateReason(current, ER_NORESPONSE, 0, NULL);
return;
}
@@ -893,7 +893,11 @@ int PortList::setStateReason(u16 portno, u8 proto, reason_t reason, u8 ttl,
Port *answer = NULL;
answer = createPort(portno, proto);
return setStateReason(answer, reason, ttl, ip_addr);
}
int PortList::setStateReason(Port *answer, reason_t reason, u8 ttl,
const struct sockaddr_storage *ip_addr) {
/* set new reason and increment its count */
answer->reason.reason_id = reason;
if (ip_addr == NULL)

View File

@@ -206,6 +206,7 @@ class PortList {
int allowed_protocol, int allowed_state) const;
int setStateReason(u16 portno, u8 proto, reason_t reason, u8 ttl, const struct sockaddr_storage *ip_addr);
int setStateReason(Port *answer, reason_t reason, u8 ttl, const struct sockaddr_storage *ip_addr);
int numscriptresults; /* Total number of scripts which produced output */