if (*p >= 0xc0) {
size_t offset;
- if ((p + 2) >= end) {
- DECODE_FAIL(INVALID_RR_LABEL);
+ if ((p + 2) > end) {
+ DECODE_FAIL(POINTER_OVERFLOWS_PACKET);
return false;
}
* Can't point to the header.
*/
if (offset < 12) {
- DECODE_FAIL(INVALID_RR_LABEL);
+ DECODE_FAIL(POINTER_TO_HEADER);
return false;
}
* Can't point to the current label.
*/
if ((packet + offset) >= start) {
- DECODE_FAIL(INVALID_RR_LABEL);
+ DECODE_FAIL(POINTER_LOOPS);
return false;
}
* 0b10 and 0b10 are forbidden
*/
if (*p > 63) {
- DECODE_FAIL(INVALID_RR_LABEL);
+ DECODE_FAIL(INVALID_POINTER);
return false;
}
/*
* It must be a length byte, which doesn't cause overflow.
*/
- if ((p + *p + 1) >= end) {
- DECODE_FAIL(INVALID_RR_LABEL);
+ if ((p + *p + 1) > end) {
+ DECODE_FAIL(LABEL_OVERFLOWS_PACKET);
return false;
}
*/
len += *p;
if (len >= 256) {
- DECODE_FAIL(INVALID_RR_LABEL);
+ DECODE_FAIL(LABEL_TOO_LONG);
return false;
}
* qtype + qclass
*/
if ((p + 4) > end) {
- DECODE_FAIL(MISSING_RR_HEADER);
+ DECODE_FAIL(MISSING_QD_HEADER);
return false;
}
{ L("resource record length overflows the packet"), DECODE_FAIL_RR_OVERFLOWS_PACKET },
{ L("more resource records than indicated in header"), DECODE_FAIL_TOO_MANY_RRS },
{ L("fewer resource records than indicated in header"), DECODE_FAIL_TOO_FEW_RRS },
+ { L("pointer overflows packet"), DECODE_FAIL_POINTER_OVERFLOWS_PACKET },
+ { L("pointer points to packet header"), DECODE_FAIL_POINTER_TO_HEADER },
+ { L("pointer creates a loop"), DECODE_FAIL_POINTER_LOOPS },
+ { L("invalid pointer"), DECODE_FAIL_INVALID_POINTER },
+ { L("label overflows the packet"), DECODE_FAIL_LABEL_OVERFLOWS_PACKET },
+ { L("too many characters in label"), DECODE_FAIL_LABEL_TOO_LONG },
+ { L("query record header is missing"), DECODE_FAIL_MISSING_QD_HEADER },
};
static size_t reason_fail_table_len = NUM_ELEMENTS(reason_fail_table);
DECODE_FAIL_RR_OVERFLOWS_PACKET,
DECODE_FAIL_TOO_MANY_RRS,
DECODE_FAIL_TOO_FEW_RRS,
+ DECODE_FAIL_POINTER_OVERFLOWS_PACKET,
+ DECODE_FAIL_POINTER_TO_HEADER,
+ DECODE_FAIL_POINTER_LOOPS,
+ DECODE_FAIL_INVALID_POINTER,
+ DECODE_FAIL_LABEL_OVERFLOWS_PACKET,
+ DECODE_FAIL_LABEL_TOO_LONG,
+ DECODE_FAIL_MISSING_QD_HEADER,
DECODE_FAIL_MAX
} fr_dns_decode_fail_t;