diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/shared/conf-parser.c | 9 | ||||
-rw-r--r-- | src/shared/conf-parser.h | 3 |
2 files changed, 12 insertions, 0 deletions
diff --git a/src/shared/conf-parser.c b/src/shared/conf-parser.c index 1640500d57..ceadfdb723 100644 --- a/src/shared/conf-parser.c +++ b/src/shared/conf-parser.c @@ -894,6 +894,15 @@ int config_parse_string( return 0; } + if (FLAGS_SET(ltype, CONFIG_PARSE_STRING_ASCII) && !ascii_is_valid(rvalue)) { + _cleanup_free_ char *escaped = NULL; + + escaped = cescape(rvalue); + log_syntax(unit, LOG_WARNING, filename, line, 0, + "Specified string contains invalid ASCII characters, ignoring: %s", strna(escaped)); + return 0; + } + return free_and_strdup_warn(s, empty_to_null(rvalue)); } diff --git a/src/shared/conf-parser.h b/src/shared/conf-parser.h index b0d6cebc97..f3044b0ca6 100644 --- a/src/shared/conf-parser.h +++ b/src/shared/conf-parser.h @@ -204,6 +204,9 @@ typedef enum Disabled { typedef enum ConfigParseStringFlags { CONFIG_PARSE_STRING_SAFE = 1 << 0, + CONFIG_PARSE_STRING_ASCII = 1 << 1, + + CONFIG_PARSE_STRING_SAFE_AND_ASCII = CONFIG_PARSE_STRING_SAFE | CONFIG_PARSE_STRING_ASCII, } ConfigParseStringFlags; #define DEFINE_CONFIG_PARSE(function, parser, msg) \ |