Merge pull request #203 from alagoutte/scan-build
fix warning found by Clang Analyzer (scan-build)
This commit is contained in:
+26
-27
@@ -552,11 +552,10 @@ void ndpi_workflow_process_packet (struct ndpi_workflow * workflow,
|
|||||||
u_int16_t radio_len;
|
u_int16_t radio_len;
|
||||||
u_int16_t fc;
|
u_int16_t fc;
|
||||||
u_int16_t type;
|
u_int16_t type;
|
||||||
int wifi_len;
|
int wifi_len = 0;
|
||||||
int llc_off;
|
int llc_off;
|
||||||
int pyld_eth_len = 0;
|
int pyld_eth_len = 0;
|
||||||
int check;
|
int check;
|
||||||
u_int32_t fcs;
|
|
||||||
u_int64_t time;
|
u_int64_t time;
|
||||||
u_int16_t ip_offset, ip_len, ip6_offset;
|
u_int16_t ip_offset, ip_len, ip6_offset;
|
||||||
u_int16_t frag_off = 0, vlan_id = 0;
|
u_int16_t frag_off = 0, vlan_id = 0;
|
||||||
@@ -646,8 +645,6 @@ void ndpi_workflow_process_packet (struct ndpi_workflow * workflow,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
fcs = header->len - 4;
|
|
||||||
|
|
||||||
/* Calculate 802.11 header length (variable) */
|
/* Calculate 802.11 header length (variable) */
|
||||||
wifi = (struct ndpi_wifi_header*)( packet + eth_offset + radio_len);
|
wifi = (struct ndpi_wifi_header*)( packet + eth_offset + radio_len);
|
||||||
fc = wifi->fc;
|
fc = wifi->fc;
|
||||||
@@ -679,31 +676,33 @@ void ndpi_workflow_process_packet (struct ndpi_workflow * workflow,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* check ether type */
|
/* check ether type */
|
||||||
if(type == VLAN) {
|
switch(type) {
|
||||||
vlan_id = ((packet[ip_offset] << 8) + packet[ip_offset+1]) & 0xFFF;
|
case VLAN:
|
||||||
type = (packet[ip_offset+2] << 8) + packet[ip_offset+3];
|
vlan_id = ((packet[ip_offset] << 8) + packet[ip_offset+1]) & 0xFFF;
|
||||||
ip_offset += 4;
|
type = (packet[ip_offset+2] << 8) + packet[ip_offset+3];
|
||||||
vlan_packet = 1;
|
|
||||||
} else if(type == MPLS_UNI || type == MPLS_MULTI) {
|
|
||||||
mpls = (struct ndpi_mpls_header *) &packet[ip_offset];
|
|
||||||
label = ntohl(mpls->label);
|
|
||||||
/* label = ntohl(*((u_int32_t*)&packet[ip_offset])); */
|
|
||||||
workflow->stats.mpls_count++;
|
|
||||||
type = ETH_P_IP, ip_offset += 4;
|
|
||||||
|
|
||||||
while((label & 0x100) != 0x100) {
|
|
||||||
ip_offset += 4;
|
ip_offset += 4;
|
||||||
|
vlan_packet = 1;
|
||||||
|
break;
|
||||||
|
case MPLS_UNI:
|
||||||
|
case MPLS_MULTI:
|
||||||
|
mpls = (struct ndpi_mpls_header *) &packet[ip_offset];
|
||||||
label = ntohl(mpls->label);
|
label = ntohl(mpls->label);
|
||||||
}
|
/* label = ntohl(*((u_int32_t*)&packet[ip_offset])); */
|
||||||
}
|
workflow->stats.mpls_count++;
|
||||||
else if(type == SLARP)
|
type = ETH_P_IP, ip_offset += 4;
|
||||||
slarp = (struct ndpi_slarp *) &packet[ip_offset];
|
|
||||||
else if(type == CISCO_D_PROTO)
|
while((label & 0x100) != 0x100) {
|
||||||
cdp = (struct ndpi_cdp *) &packet[ip_offset];
|
ip_offset += 4;
|
||||||
else if(type == PPPoE) {
|
label = ntohl(mpls->label);
|
||||||
workflow->stats.pppoe_count++;
|
}
|
||||||
type = ETH_P_IP;
|
break;
|
||||||
ip_offset += 8;
|
case PPPoE:
|
||||||
|
workflow->stats.pppoe_count++;
|
||||||
|
type = ETH_P_IP;
|
||||||
|
ip_offset += 8;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
workflow->stats.vlan_count += vlan_packet;
|
workflow->stats.vlan_count += vlan_packet;
|
||||||
|
|||||||
+5
-3
@@ -550,7 +550,11 @@ static int ndpi_string_to_automa(struct ndpi_detection_module_struct *ndpi_struc
|
|||||||
if(automa->ac_automa == NULL) return(-2);
|
if(automa->ac_automa == NULL) return(-2);
|
||||||
ac_pattern.astring = value;
|
ac_pattern.astring = value;
|
||||||
ac_pattern.rep.number = protocol_id;
|
ac_pattern.rep.number = protocol_id;
|
||||||
ac_pattern.length = strlen(ac_pattern.astring);
|
if(value == NULL)
|
||||||
|
ac_pattern.length = 0;
|
||||||
|
else
|
||||||
|
ac_pattern.length = strlen(ac_pattern.astring);
|
||||||
|
|
||||||
ac_automata_add(((AC_AUTOMATA_t*)automa->ac_automa), &ac_pattern);
|
ac_automata_add(((AC_AUTOMATA_t*)automa->ac_automa), &ac_pattern);
|
||||||
|
|
||||||
return(0);
|
return(0);
|
||||||
@@ -3391,8 +3395,6 @@ ndpi_protocol ndpi_detection_process_packet(struct ndpi_detection_module_struct
|
|||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
protocol = flow->packet.iph->protocol;
|
protocol = flow->packet.iph->protocol;
|
||||||
saddr = ntohl(flow->packet.iph->saddr);
|
|
||||||
daddr = ntohl(flow->packet.iph->daddr);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(flow->packet.udp) sport = ntohs(flow->packet.udp->source), dport = ntohs(flow->packet.udp->dest);
|
if(flow->packet.udp) sport = ntohs(flow->packet.udp->source), dport = ntohs(flow->packet.udp->dest);
|
||||||
|
|||||||
@@ -135,7 +135,6 @@ static u_int8_t ndpi_int_search_bittorrent_tcp_zero(struct ndpi_detection_module
|
|||||||
|| memcmp(packet->payload, "POST ", 5) == 0)) {
|
|| memcmp(packet->payload, "POST ", 5) == 0)) {
|
||||||
const u_int8_t *ptr = &packet->payload[4];
|
const u_int8_t *ptr = &packet->payload[4];
|
||||||
u_int16_t len = packet->payload_packet_len - 4;
|
u_int16_t len = packet->payload_packet_len - 4;
|
||||||
a = 0;
|
|
||||||
|
|
||||||
|
|
||||||
/* parse complete get packet here into line structure elements */
|
/* parse complete get packet here into line structure elements */
|
||||||
|
|||||||
@@ -230,7 +230,6 @@ static void ndpi_check_ftp_data(struct ndpi_detection_module_struct *ndpi_struct
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ndpi_search_ftp_data(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow) {
|
void ndpi_search_ftp_data(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow) {
|
||||||
struct ndpi_packet_struct *packet = &flow->packet;
|
|
||||||
|
|
||||||
/* Break after 20 packets. */
|
/* Break after 20 packets. */
|
||||||
if(flow->packet_counter > 20) {
|
if(flow->packet_counter > 20) {
|
||||||
|
|||||||
@@ -48,7 +48,6 @@ void ndpi_search_rtcp(struct ndpi_detection_module_struct *ndpi_struct, struct n
|
|||||||
offset += rtcp_section_len;
|
offset += rtcp_section_len;
|
||||||
}
|
}
|
||||||
|
|
||||||
sport = ntohs(packet->udp->source), dport = ntohs(packet->udp->dest);
|
|
||||||
NDPI_LOG(NDPI_PROTOCOL_RTCP, ndpi_struct, NDPI_LOG_DEBUG, "calculating dport over udp.\n");
|
NDPI_LOG(NDPI_PROTOCOL_RTCP, ndpi_struct, NDPI_LOG_DEBUG, "calculating dport over udp.\n");
|
||||||
/* TODO changed a pair of length condition to the && from ||. Is it correct? */
|
/* TODO changed a pair of length condition to the && from ||. Is it correct? */
|
||||||
if(((packet->payload_packet_len >= 28 && packet->payload_packet_len <= 1200) &&
|
if(((packet->payload_packet_len >= 28 && packet->payload_packet_len <= 1200) &&
|
||||||
|
|||||||
Reference in New Issue
Block a user