Fix some warnings and two errors found while fuzzing (#1844)
Fix CI See: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=54614
This commit is contained in:
@@ -538,6 +538,12 @@ void ndpi_set_proto_defaults(struct ndpi_detection_module_struct *ndpi_str,
|
|||||||
}
|
}
|
||||||
|
|
||||||
name = ndpi_strdup(protoName);
|
name = ndpi_strdup(protoName);
|
||||||
|
if(!name) {
|
||||||
|
#ifdef DEBUG
|
||||||
|
NDPI_LOG_ERR(ndpi_str, "[NDPI] %s/protoId=%d: mem allocation error\n", protoName, protoId);
|
||||||
|
#endif
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if(ndpi_str->proto_defaults[protoId].protoName)
|
if(ndpi_str->proto_defaults[protoId].protoName)
|
||||||
ndpi_free(ndpi_str->proto_defaults[protoId].protoName);
|
ndpi_free(ndpi_str->proto_defaults[protoId].protoName);
|
||||||
|
|||||||
+14
-2
@@ -354,7 +354,9 @@ static int search_valid_dns(struct ndpi_detection_module_struct *ndpi_struct,
|
|||||||
/* This is a good reply: we dissect it both for request and response */
|
/* This is a good reply: we dissect it both for request and response */
|
||||||
|
|
||||||
if(dns_header->num_queries > 0) {
|
if(dns_header->num_queries > 0) {
|
||||||
|
#ifdef DNS_DEBUG
|
||||||
u_int16_t rsp_type;
|
u_int16_t rsp_type;
|
||||||
|
#endif
|
||||||
u_int16_t num;
|
u_int16_t num;
|
||||||
|
|
||||||
for(num = 0; num < dns_header->num_queries; num++) {
|
for(num = 0; num < dns_header->num_queries; num++) {
|
||||||
@@ -374,7 +376,12 @@ static int search_valid_dns(struct ndpi_detection_module_struct *ndpi_struct,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* To avoid warning: variable ‘rsp_type’ set but not used [-Wunused-but-set-variable] */
|
||||||
|
#ifdef DNS_DEBUG
|
||||||
rsp_type = get16(&x, packet->payload);
|
rsp_type = get16(&x, packet->payload);
|
||||||
|
#else
|
||||||
|
get16(&x, packet->payload);
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef DNS_DEBUG
|
#ifdef DNS_DEBUG
|
||||||
printf("[DNS] [response (query)] response_type=%d\n", rsp_type);
|
printf("[DNS] [response (query)] response_type=%d\n", rsp_type);
|
||||||
@@ -483,8 +490,9 @@ static int search_valid_dns(struct ndpi_detection_module_struct *ndpi_struct,
|
|||||||
as we need to update the 'x' offset
|
as we need to update the 'x' offset
|
||||||
*/
|
*/
|
||||||
if(dns_header->authority_rrs > 0) {
|
if(dns_header->authority_rrs > 0) {
|
||||||
|
#ifdef DNS_DEBUG
|
||||||
u_int16_t rsp_type;
|
u_int16_t rsp_type;
|
||||||
u_int32_t rsp_ttl;
|
#endif
|
||||||
u_int16_t num;
|
u_int16_t num;
|
||||||
|
|
||||||
for(num = 0; num < dns_header->authority_rrs; num++) {
|
for(num = 0; num < dns_header->authority_rrs; num++) {
|
||||||
@@ -504,8 +512,12 @@ static int search_valid_dns(struct ndpi_detection_module_struct *ndpi_struct,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* To avoid warning: variable ‘rsp_type’ set but not used [-Wunused-but-set-variable] */
|
||||||
|
#ifdef DNS_DEBUG
|
||||||
rsp_type = get16(&x, packet->payload);
|
rsp_type = get16(&x, packet->payload);
|
||||||
rsp_ttl = ntohl(*((u_int32_t*)&packet->payload[x+2]));
|
#else
|
||||||
|
get16(&x, packet->payload);
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef DNS_DEBUG
|
#ifdef DNS_DEBUG
|
||||||
printf("[DNS] [RRS response] response_type=%d\n", rsp_type);
|
printf("[DNS] [RRS response] response_type=%d\n", rsp_type);
|
||||||
|
|||||||
+1
-1
@@ -474,7 +474,7 @@ int ac_automata_search (AC_AUTOMATA_t * thiz,
|
|||||||
} else {
|
} else {
|
||||||
curr = next;
|
curr = next;
|
||||||
position++;
|
position++;
|
||||||
if(curr->final) {
|
if(curr->final && curr->matched_patterns) {
|
||||||
/* select best match */
|
/* select best match */
|
||||||
match->match_map = ac_automata_exact_match(curr->matched_patterns,position,txt);
|
match->match_map = ac_automata_exact_match(curr->matched_patterns,position,txt);
|
||||||
if(match->match_map) {
|
if(match->match_map) {
|
||||||
|
|||||||
Reference in New Issue
Block a user