mirror of
https://github.com/nmap/nmap.git
synced 2026-05-13 08:46:45 +00:00
Avoid bad downcast
This commit is contained in:
parent
36f0b76bdb
commit
c3140c4799
1 changed files with 8 additions and 5 deletions
|
|
@ -1710,18 +1710,21 @@ bool PacketParser::is_response(PacketElement *sent, PacketElement *rcvd){
|
||||||
/* So far we've verified that the ICMP error contains an IP datagram that matches
|
/* So far we've verified that the ICMP error contains an IP datagram that matches
|
||||||
* what we sent. Now, let's find the upper layer protocol (skip extension
|
* what we sent. Now, let's find the upper layer protocol (skip extension
|
||||||
* headers and the like until we find some transport protocol). */
|
* headers and the like until we find some transport protocol). */
|
||||||
TransportLayerElement *layer4error=(TransportLayerElement *)iperror->getNextElement();
|
iperror = dynamic_cast<NetworkLayerElement *>(iperror->getNextElement());
|
||||||
while(layer4error!=NULL){
|
while(iperror!=NULL){
|
||||||
if(layer4error->protocol_id()==HEADER_TYPE_UDP || layer4error->protocol_id()==HEADER_TYPE_TCP ){
|
if(iperror->protocol_id()==HEADER_TYPE_UDP || iperror->protocol_id()==HEADER_TYPE_TCP ){
|
||||||
break;
|
break;
|
||||||
}else{
|
}else{
|
||||||
layer4error=(TransportLayerElement *)layer4error->getNextElement();
|
iperror = dynamic_cast<NetworkLayerElement *>(iperror->getNextElement());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(layer4error==NULL)
|
if(iperror==NULL)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
/* Now make sure we see the same port numbers */
|
/* Now make sure we see the same port numbers */
|
||||||
|
TransportLayerElement *layer4error = dynamic_cast<TransportLayerElement *>(iperror);
|
||||||
|
if (layer4error == NULL)
|
||||||
|
return false;
|
||||||
if( layer4error->getSourcePort() != ((TransportLayerElement *)sent_layer4)->getSourcePort() )
|
if( layer4error->getSourcePort() != ((TransportLayerElement *)sent_layer4)->getSourcePort() )
|
||||||
return false;
|
return false;
|
||||||
if( layer4error->getDestinationPort() != ((TransportLayerElement *)sent_layer4)->getDestinationPort() )
|
if( layer4error->getDestinationPort() != ((TransportLayerElement *)sent_layer4)->getDestinationPort() )
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue