4 int __dns_parse(const unsigned char *r, int rlen, int (*callback)(void *, int, const void *, int, const void *), void *ctx)
7 const unsigned char *p;
10 if (rlen<12) return -1;
11 if ((r[3]&15)) return 0;
13 qdcount = r[4]*256 + r[5];
14 ancount = r[6]*256 + r[7];
15 if (qdcount+ancount > 64) return -1;
17 while (p-r < rlen && *p-1U < 127) p++;
18 if (*p>193 || (*p==193 && p[1]>254) || p>r+rlen-6)
23 while (p-r < rlen && *p-1U < 127) p++;
24 if (*p>193 || (*p==193 && p[1]>254) || p>r+rlen-6)
27 len = p[8]*256 + p[9];
28 if (p+len > r+rlen) return -1;
29 if (callback(ctx, p[1], p+10, len, r) < 0) return -1;