mirror of
https://github.com/pi-hole/dnsmasq.git
synced 2025-12-19 18:28:25 +00:00
Convert DNS names in logs to all lower case.
0x20 encoding makes them look odd, otherwise.
This commit is contained in:
22
src/cache.c
22
src/cache.c
@@ -1852,14 +1852,30 @@ int cache_make_stat(struct txt_record *t)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* There can be names in the cache containing control chars, don't
|
/* There can be names in the cache containing control chars, don't
|
||||||
mess up logging or open security holes. */
|
mess up logging or open security holes. Also convert to all-LC
|
||||||
|
so that 0x20-encoding doesn't make logs look like ransom notes
|
||||||
|
made out of letters cut from a newspaper.
|
||||||
|
Overwrites daemon->workspacename */
|
||||||
static char *sanitise(char *name)
|
static char *sanitise(char *name)
|
||||||
{
|
{
|
||||||
unsigned char *r;
|
unsigned char *r = (unsigned char *)name;
|
||||||
|
|
||||||
if (name)
|
if (name)
|
||||||
for (r = (unsigned char *)name; *r; r++)
|
{
|
||||||
|
char *d = name = daemon->workspacename;
|
||||||
|
|
||||||
|
for (; *r; r++, d++)
|
||||||
if (!isprint((int)*r))
|
if (!isprint((int)*r))
|
||||||
return "<name unprintable>";
|
return "<name unprintable>";
|
||||||
|
else
|
||||||
|
{
|
||||||
|
unsigned char c = *r;
|
||||||
|
|
||||||
|
*d = (char)((c >= 'A' && c <= 'Z') ? c + 'a' - 'A' : c);
|
||||||
|
}
|
||||||
|
|
||||||
|
*d = 0;
|
||||||
|
}
|
||||||
|
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user