From 4d3aa6c6e0282523e8b2a5b29c0917e63e787395 Mon Sep 17 00:00:00 2001 From: Yves Rutschle Date: Tue, 3 Mar 2026 22:05:01 +0100 Subject: [PATCH] sanity checks that regex options are only used with the right probe and with libpcre2 support compiled in --- sslh-main.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/sslh-main.c b/sslh-main.c index fd4a967..5dd36df 100644 --- a/sslh-main.c +++ b/sslh-main.c @@ -220,6 +220,23 @@ static void config_protocols() } } +static void config_sanity_regex(const struct sslhcfg_protocols_item* prot) +{ + if (prot->regex_patterns_len > 0) { + if (strcmp(prot->name, "regex") != 0) { + print_message(msg_config_error, "name: \"%s\"; host: \"%s\"; port: \"%s\": " + "regex_patterns setting is only applicable to `regex' probe.\n" + "This setting will be ignored\n", + prot->name, prot->host, prot->port); + } +#ifndef ENABLE_REGEX + print_message(msg_config_error, "name: \"%s\"; host: \"%s\"; port: \"%s\": " + "Uses regex_patterns, but libpcre2 support was not compiled in.\n" + "This setting will be ignored.\n", + prot->name, prot->host, prot->port); +#endif + } +} void config_sanity_check(struct sslhcfg_item* cfg) { @@ -249,6 +266,8 @@ void config_sanity_check(struct sslhcfg_item* cfg) } } + config_sanity_regex(&cfg->protocols[i]); + if (cfg->protocols[i].is_udp) { if (cfg->protocols[i].tfo_ok) { print_message(msg_config_error, "name: \"%s\"; host: \"%s\"; port: \"%s\": "