diff options
author | Beyers Cronje <bcronje@gmail.com> | 2015-08-26 00:49:01 +0200 |
---|---|---|
committer | Beyers Cronje <bcronje@gmail.com> | 2015-08-26 00:49:01 +0200 |
commit | 8fe318495fb0580732c007fddf3d14fa1c5abd8e (patch) | |
tree | 6e67671dc64e6f4e5ae27bf98d830b9b0bcf6251 /src | |
parent | 26ce076f61dd168b2e9b34c059ce3be34bc11953 (diff) |
Do not write to packet.iph, which should be readonly.
Resolves issue #77
Diffstat (limited to 'src')
-rw-r--r-- | src/lib/ndpi_main.c | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/src/lib/ndpi_main.c b/src/lib/ndpi_main.c index c4b214448..5fb0b6cd8 100644 --- a/src/lib/ndpi_main.c +++ b/src/lib/ndpi_main.c @@ -1701,8 +1701,10 @@ u_int8_t ndpi_is_tor_flow(struct ndpi_detection_module_struct *ndpi_struct, if(packet->tcp != NULL) { if(flow->packet.iph) { - if(tor_ptree_match(ndpi_struct, (struct in_addr *)&packet->iph->saddr) - || tor_ptree_match(ndpi_struct, (struct in_addr *)&packet->iph->daddr)) { + struct in_addr saddr = { packet->iph->saddr }; + struct in_addr daddr = { packet->iph->daddr }; + if(tor_ptree_match(ndpi_struct, &saddr) + || tor_ptree_match(ndpi_struct, &daddr)) { return(1); } } @@ -3418,10 +3420,12 @@ ndpi_protocol ndpi_detection_process_packet(struct ndpi_detection_module_struct if((ret.master_protocol == NDPI_PROTOCOL_UNKNOWN) && flow->packet.iph) { - struct ndpi_packet_struct *packet = &flow->packet; + struct in_addr pin = { flow->packet.iph->saddr }; - if((ret.master_protocol = ndpi_network_ptree_match(ndpi_struct, (struct in_addr *)&packet->iph->saddr)) == NDPI_PROTOCOL_UNKNOWN) - ret.master_protocol = ndpi_network_ptree_match(ndpi_struct, (struct in_addr *)&packet->iph->daddr); + if((ret.master_protocol = ndpi_network_ptree_match(ndpi_struct, &pin)) == NDPI_PROTOCOL_UNKNOWN) { + pin.s_addr = flow->packet.iph->daddr; + ret.master_protocol = ndpi_network_ptree_match(ndpi_struct, &pin); + } /* Swap proocols in case of success */ if(ret.master_protocol != NDPI_PROTOCOL_UNKNOWN) { |