From bb8811d472a136335ecf4965419504df7d592a08 Mon Sep 17 00:00:00 2001 From: Simon Kelley Date: Mon, 20 Jan 2025 15:25:26 +0000 Subject: [PATCH] Convert DNS names in logs to all lower case. 0x20 encoding makes them look odd, otherwise. --- src/cache.c | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/src/cache.c b/src/cache.c index f2aecca..fd959a8 100644 --- a/src/cache.c +++ b/src/cache.c @@ -1852,15 +1852,31 @@ int cache_make_stat(struct txt_record *t) #endif /* 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) { - unsigned char *r; + unsigned char *r = (unsigned char *)name; + if (name) - for (r = (unsigned char *)name; *r; r++) - if (!isprint((int)*r)) - return ""; - + { + char *d = name = daemon->workspacename; + + for (; *r; r++, d++) + if (!isprint((int)*r)) + return ""; + else + { + unsigned char c = *r; + + *d = (char)((c >= 'A' && c <= 'Z') ? c + 'a' - 'A' : c); + } + + *d = 0; + } + return name; }