Allow control characters in names in the cache, handle when logging.

This commit is contained in:
Simon Kelley
2015-03-29 22:17:14 +01:00
parent 1e153945de
commit 394ff492da
3 changed files with 37 additions and 23 deletions

View File

@@ -1399,6 +1399,19 @@ int cache_make_stat(struct txt_record *t)
return 1;
}
/* There can be names in the cache containing control chars, don't
mess up logging or open security holes. */
static char *sanitise(char *name)
{
unsigned char *r;
for (r = (unsigned char *)name; *r; r++)
if (!isprint((int)*r))
return "<name unprintable>";
return name;
}
void dump_cache(time_t now)
{
struct server *serv, *serv1;
@@ -1452,9 +1465,9 @@ void dump_cache(time_t now)
*a = 0;
if (strlen(n) == 0 && !(cache->flags & F_REVERSE))
n = "<Root>";
p += sprintf(p, "%-30.30s ", n);
p += sprintf(p, "%-30.30s ", sanitise(n));
if ((cache->flags & F_CNAME) && !is_outdated_cname_pointer(cache))
a = cache_get_cname_target(cache);
a = sanitise(cache_get_cname_target(cache));
#ifdef HAVE_DNSSEC
else if (cache->flags & F_DS)
{
@@ -1587,6 +1600,8 @@ void log_query(unsigned int flags, char *name, struct all_addr *addr, char *arg)
if (!option_bool(OPT_LOG))
return;
name = sanitise(name);
if (addr)
{
if (flags & F_KEYTAG)