diff options
author | Ivan Nardi <12729895+IvanNardi@users.noreply.github.com> | 2023-01-03 13:21:54 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-01-03 13:21:54 +0100 |
commit | 9c83f0f3c590a896a5edf185040cbfeee8eb10a6 (patch) | |
tree | 8d73f9df2bf5bd3e1718a762994c19bc3eb25bff /src/lib/protocols/dns.c | |
parent | cb15d2b328437f2a05d65cf4aaa5a9903cc42f53 (diff) |
Fix some warnings and two errors found while fuzzing (#1844)
Fix CI
See: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=54614
Diffstat (limited to 'src/lib/protocols/dns.c')
-rw-r--r-- | src/lib/protocols/dns.c | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/src/lib/protocols/dns.c b/src/lib/protocols/dns.c index 48da46e39..d99e94e8b 100644 --- a/src/lib/protocols/dns.c +++ b/src/lib/protocols/dns.c @@ -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 */ if(dns_header->num_queries > 0) { +#ifdef DNS_DEBUG u_int16_t rsp_type; +#endif u_int16_t 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; } + /* To avoid warning: variable ‘rsp_type’ set but not used [-Wunused-but-set-variable] */ +#ifdef DNS_DEBUG rsp_type = get16(&x, packet->payload); +#else + get16(&x, packet->payload); +#endif #ifdef DNS_DEBUG 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 */ if(dns_header->authority_rrs > 0) { +#ifdef DNS_DEBUG u_int16_t rsp_type; - u_int32_t rsp_ttl; +#endif u_int16_t 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; } + /* To avoid warning: variable ‘rsp_type’ set but not used [-Wunused-but-set-variable] */ +#ifdef DNS_DEBUG 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 printf("[DNS] [RRS response] response_type=%d\n", rsp_type); |