Commit 62cb936c authored by Simon Kelley's avatar Simon Kelley

Security fix, CVE-2017-14491, DNS heap buffer overflow.

Further fix to 0549c73b
Handles case when RR name is not a pointer to the question,
only occurs for some auth-mode replies, therefore not
detected by fuzzing (?)
parent 39921d03
...@@ -1086,19 +1086,15 @@ int add_resource_record(struct dns_header *header, char *limit, int *truncp, int ...@@ -1086,19 +1086,15 @@ int add_resource_record(struct dns_header *header, char *limit, int *truncp, int
va_start(ap, format); /* make ap point to 1st unamed argument */ va_start(ap, format); /* make ap point to 1st unamed argument */
/* nameoffset (1 or 2) + type (2) + class (2) + ttl (4) + 0 (2) */
CHECK_LIMIT(12);
if (nameoffset > 0) if (nameoffset > 0)
{ {
CHECK_LIMIT(2);
PUTSHORT(nameoffset | 0xc000, p); PUTSHORT(nameoffset | 0xc000, p);
} }
else else
{ {
char *name = va_arg(ap, char *); char *name = va_arg(ap, char *);
if (name) if (name && !(p = do_rfc1035_name(p, name, limit)))
p = do_rfc1035_name(p, name, limit);
if (!p)
{ {
va_end(ap); va_end(ap);
goto truncated; goto truncated;
...@@ -1106,11 +1102,18 @@ int add_resource_record(struct dns_header *header, char *limit, int *truncp, int ...@@ -1106,11 +1102,18 @@ int add_resource_record(struct dns_header *header, char *limit, int *truncp, int
if (nameoffset < 0) if (nameoffset < 0)
{ {
CHECK_LIMIT(2);
PUTSHORT(-nameoffset | 0xc000, p); PUTSHORT(-nameoffset | 0xc000, p);
} }
else else
{
CHECK_LIMIT(1);
*p++ = 0; *p++ = 0;
} }
}
/* type (2) + class (2) + ttl (4) + rdlen (2) */
CHECK_LIMIT(10);
PUTSHORT(type, p); PUTSHORT(type, p);
PUTSHORT(class, p); PUTSHORT(class, p);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment