mirror of
https://github.com/yarrick/iodine.git
synced 2024-09-08 12:07:04 +00:00
Make sure replies with errors get the name parsed
This commit is contained in:
parent
269499ba43
commit
acd264b435
10
src/dns.c
10
src/dns.c
|
@ -302,14 +302,15 @@ dns_decode(char *buf, size_t buflen, struct query *q, qr_t qr, char *packet, siz
|
||||||
|
|
||||||
switch (qr) {
|
switch (qr) {
|
||||||
case QR_ANSWER:
|
case QR_ANSWER:
|
||||||
if(qdcount < 1 || ancount < 1) {
|
if(qdcount < 1) {
|
||||||
/* We may get both CNAME and A, then ancount=2 */
|
/* We need a question */
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (q != NULL)
|
if (q != NULL)
|
||||||
q->id = id;
|
q->id = id;
|
||||||
|
|
||||||
|
/* Read name even if no answer, to give better error message */
|
||||||
readname(packet, packetlen, &data, name, sizeof(name));
|
readname(packet, packetlen, &data, name, sizeof(name));
|
||||||
CHECKLEN(4);
|
CHECKLEN(4);
|
||||||
readshort(packet, &data, &type);
|
readshort(packet, &data, &type);
|
||||||
|
@ -322,6 +323,11 @@ dns_decode(char *buf, size_t buflen, struct query *q, qr_t qr, char *packet, siz
|
||||||
q->name[1] = '\0';
|
q->name[1] = '\0';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (ancount < 1) {
|
||||||
|
/* We may get both CNAME and A, then ancount=2 */
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
/* Assume that first answer is NULL/CNAME that we wanted */
|
/* Assume that first answer is NULL/CNAME that we wanted */
|
||||||
readname(packet, packetlen, &data, name, sizeof(name));
|
readname(packet, packetlen, &data, name, sizeof(name));
|
||||||
CHECKLEN(10);
|
CHECKLEN(10);
|
||||||
|
|
Loading…
Reference in a new issue