mirror of
https://github.com/M66B/NetGuard.git
synced 2025-01-03 05:44:14 +00:00
Prevent buffer overflow
This commit is contained in:
parent
e90a8440f5
commit
e0bd3eff49
1 changed files with 11 additions and 4 deletions
|
@ -135,10 +135,17 @@ void parse_dns_response(const struct arguments *args, const struct ng_session *s
|
||||||
(qtype == DNS_QTYPE_A || qtype == DNS_QTYPE_AAAA)) {
|
(qtype == DNS_QTYPE_A || qtype == DNS_QTYPE_AAAA)) {
|
||||||
|
|
||||||
char rd[INET6_ADDRSTRLEN + 1];
|
char rd[INET6_ADDRSTRLEN + 1];
|
||||||
if (qtype == DNS_QTYPE_A)
|
if (qtype == DNS_QTYPE_A) {
|
||||||
|
if (off + sizeof(__be32) < *datalen)
|
||||||
inet_ntop(AF_INET, data + off, rd, sizeof(rd));
|
inet_ntop(AF_INET, data + off, rd, sizeof(rd));
|
||||||
else if (qclass == DNS_QCLASS_IN && qtype == DNS_QTYPE_AAAA)
|
else
|
||||||
|
return;
|
||||||
|
} else if (qclass == DNS_QCLASS_IN && qtype == DNS_QTYPE_AAAA) {
|
||||||
|
if (off + sizeof(struct in6_addr) < *datalen)
|
||||||
inet_ntop(AF_INET6, data + off, rd, sizeof(rd));
|
inet_ntop(AF_INET6, data + off, rd, sizeof(rd));
|
||||||
|
else
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
dns_resolved(args, qname, name, rd, ttl);
|
dns_resolved(args, qname, name, rd, ttl);
|
||||||
log_android(ANDROID_LOG_DEBUG,
|
log_android(ANDROID_LOG_DEBUG,
|
||||||
|
|
Loading…
Reference in a new issue