mirror of
https://github.com/M66B/NetGuard.git
synced 2024-12-27 02:09:41 +00:00
Native the maximum domain name length is 255 octets
http://tools.ietf.org/html/rfc3986#page-21
This commit is contained in:
parent
dc0980e87f
commit
87b3d0c33c
2 changed files with 5 additions and 7 deletions
|
@ -26,9 +26,7 @@ int32_t get_qname(const uint8_t *data, const size_t datalen, uint16_t off, char
|
|||
uint8_t noff = 0;
|
||||
uint16_t ptr = off;
|
||||
uint8_t len = *(data + ptr);
|
||||
uint8_t parts = 0;
|
||||
while (len && parts < 10) {
|
||||
parts++;
|
||||
while (len) {
|
||||
if (len & 0xC0) {
|
||||
ptr = (uint16_t) ((len & 0x3F) * 256 + *(data + ptr + 1));
|
||||
len = *(data + ptr);
|
||||
|
@ -38,7 +36,7 @@ int32_t get_qname(const uint8_t *data, const size_t datalen, uint16_t off, char
|
|||
off += 2;
|
||||
}
|
||||
}
|
||||
else if (ptr + 1 + len <= datalen) {
|
||||
else if (ptr + 1 + len <= datalen && noff + len <= DNS_QNAME_MAX) {
|
||||
memcpy(qname + noff, data + ptr + 1, len);
|
||||
*(qname + noff + len) = '.';
|
||||
noff += (len + 1);
|
||||
|
@ -52,12 +50,12 @@ int32_t get_qname(const uint8_t *data, const size_t datalen, uint16_t off, char
|
|||
ptr++;
|
||||
|
||||
if (len > 0 || noff == 0) {
|
||||
log_android(ANDROID_LOG_ERROR, "DNS qname invalid len %d noff %d part %d", len, noff,
|
||||
parts);
|
||||
log_android(ANDROID_LOG_ERROR, "DNS qname invalid len %d noff %d", len, noff);
|
||||
return -1;
|
||||
}
|
||||
|
||||
*(qname + noff - 1) = 0;
|
||||
log_android(ANDROID_LOG_DEBUG, "qname %s", qname);
|
||||
|
||||
return (c ? off : ptr);
|
||||
}
|
||||
|
|
|
@ -206,7 +206,7 @@ typedef struct pcaprec_hdr_s {
|
|||
#define DNS_QTYPE_A 1 // IPv4
|
||||
#define DNS_QTYPE_AAAA 28 // IPv6
|
||||
|
||||
#define DNS_QNAME_MAX 63
|
||||
#define DNS_QNAME_MAX 255
|
||||
#define DNS_TTL (10 * 60) // seconds
|
||||
|
||||
struct dns_header {
|
||||
|
|
Loading…
Reference in a new issue