diff options
-rw-r--r-- | llmnr-query.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/llmnr-query.c b/llmnr-query.c index fefcf0b..27a2034 100644 --- a/llmnr-query.c +++ b/llmnr-query.c @@ -306,9 +306,13 @@ int main(int argc, char **argv) /* compression? */ if (nl & 0xC0) { uint16_t ptr = (nl & 0x3F) << 8 | *pkt_put(p, 1); - name = (char *)p->data + ptr + 1; - } else + if (ptr < p->size - 1) + name = (char *)p->data + ptr + 1; + else + name = "<invalid>"; + } else { name = (char *)pkt_put(p, nl + 1); + } type = htons(*(uint16_t *)pkt_put(p, sizeof(type))); clss = htons(*(uint16_t *)pkt_put(p, sizeof(clss))); |