cppcheck: fix possible null pointer dereference

[nfq/desync.c:1242] -> [nfq/desync.c:1243]: (warning) Either the condition 'if(ip6hdr)' is redundant or there is possible null pointer dereference: ip6hdr.
[nfq/protocol.c:280] -> [nfq/protocol.c:284]: (warning) Either the condition 'if(ext&&len_host)' is redundant or there is possible null pointer dereference: ext.
[tpws/protocol.c:270] -> [tpws/protocol.c:274]: (warning) Either the condition 'if(ext&&len_host)' is redundant or there is possible null pointer dereference: ext.
This commit is contained in:
[anp/hsw] 2024-08-03 20:51:53 +07:00
parent 6fca1223b3
commit 9574539292
3 changed files with 10 additions and 5 deletions

View File

@ -1236,9 +1236,14 @@ static uint8_t dpi_desync_udp_packet_play(bool replay, size_t reasm_offset, uint
if (!replay && !process_desync_interval(ctrack)) return verdict;
uint32_t desync_fwmark = fwmark | params.desync_fwmark;
ttl_orig = ip ? ip->ip_ttl : ip6hdr->ip6_ctlun.ip6_un1.ip6_un1_hlim;
if (ip6hdr) ttl_fake = params.desync_ttl6 ? params.desync_ttl6 : ttl_orig;
else ttl_fake = params.desync_ttl ? params.desync_ttl : ttl_orig;
if (ip6hdr) {
ttl_orig = ip ? ip->ip_ttl : ip6hdr->ip6_ctlun.ip6_un1.ip6_un1_hlim;
ttl_fake = params.desync_ttl6 ? params.desync_ttl6 : ttl_orig;
} else {
ttl_orig = ip ? ip->ip_ttl : 0;
ttl_fake = params.desync_ttl ? params.desync_ttl : ttl_orig;
}
extract_endpoints(ip, ip6hdr, NULL, udphdr, &src, &dst);
if (len_payload)

View File

@ -277,7 +277,7 @@ static bool TLSExtractHostFromExt(const uint8_t *ext, size_t elen, char *host, s
// u16 data+0 - name list length
// u8 data+2 - server name type. 0=host_name
// u16 data+3 - server name length
if (elen < 5 || ext[2] != 0) return false;
if (elen < 5 || (ext && ext[2] != 0)) return false;
size_t slen = pntoh16(ext + 3);
ext += 5; elen -= 5;
if (slen < elen) return false;

View File

@ -267,7 +267,7 @@ static bool TLSExtractHostFromExt(const uint8_t *ext, size_t elen, char *host, s
// u16 data+0 - name list length
// u8 data+2 - server name type. 0=host_name
// u16 data+3 - server name length
if (elen < 5 || ext[2] != 0) return false;
if (elen < 5 || (ext && ext[2] != 0)) return false;
size_t slen = pntoh16(ext + 3);
ext += 5; elen -= 5;
if (slen < elen) return false;