Skip to content

Commit 9816057

Browse files
committed
Enfore no-newline limitiation for a few additional config items
Signed-off-by: Dominik <[email protected]>
1 parent eb50c8e commit 9816057

2 files changed

Lines changed: 15 additions & 2 deletions

File tree

src/config/config.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -641,7 +641,7 @@ void initConfig(struct config *conf)
641641
conf->dns.cache.rrtype.t = CONF_STRING;
642642
conf->dns.cache.rrtype.f = FLAG_RESTART_FTL;
643643
conf->dns.cache.rrtype.d.s = (char*)"ANY";
644-
conf->dns.cache.rrtype.c = validate_stub; // Only type-based checking
644+
conf->dns.cache.rrtype.c = validate_str_no_newline;
645645

646646
// sub-struct dns.blocking
647647
conf->dns.blocking.active.k = "dns.blocking.active";
@@ -1408,7 +1408,7 @@ void initConfig(struct config *conf)
14081408
conf->misc.dnsmasq_lines.t = CONF_JSON_STRING_ARRAY;
14091409
conf->misc.dnsmasq_lines.f = FLAG_RESTART_FTL;
14101410
conf->misc.dnsmasq_lines.d.json = cJSON_CreateArray();
1411-
conf->misc.dnsmasq_lines.c = validate_stub; // Type-based checking + dnsmasq syntax checking
1411+
conf->misc.dnsmasq_lines.c = validate_array_no_newline;
14121412

14131413
conf->misc.extraLogging.k = "misc.extraLogging";
14141414
conf->misc.extraLogging.h = "Log additional information about queries and replies to pihole.log\n\n When this setting is enabled, the log has extra information at the start of each line. This consists of a serial number which ties together the log lines associated with an individual query, and the IP address of the requestor. This setting is only effective if dns.queryLogging is enabled, too. This option is only useful for debugging and is not recommended for normal use.";

src/config/validator.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -552,6 +552,19 @@ bool validate_dns_revServers(union conf_value *val, const char *key, char err[VA
552552
free(str);
553553
return false;
554554
}
555+
556+
// Ensure there are no newline characters in the entry
557+
const unsigned int len = strlen(item->valuestring);
558+
for(unsigned int k = 0; k < len; k++)
559+
{
560+
if(item->valuestring[k] == '\n' || item->valuestring[k] == '\r')
561+
{
562+
snprintf(err, VALIDATOR_ERRBUF_LEN, "%s[%d]: contains newline characters",
563+
key, i);
564+
free(str);
565+
return false;
566+
}
567+
}
555568
}
556569

557570
// Return success

0 commit comments

Comments
 (0)