From f6d848d58cf01174ffb22dd8f9fd5dfabc434bd0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20M=C3=A4kel=C3=A4?= Date: Thu, 30 Jan 2020 10:44:00 +0200 Subject: [PATCH] MXS-2859: Treat newlines in strings as errors Allowing raw newlines in string values breaks configuration serialization. --- server/core/config_runtime.cc | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/server/core/config_runtime.cc b/server/core/config_runtime.cc index efdb097e7..77a1598ce 100644 --- a/server/core/config_runtime.cc +++ b/server/core/config_runtime.cc @@ -2129,6 +2129,21 @@ static bool validate_object_json(json_t* json, if (is_valid_resource_body(json)) { + if (json_t* parameters = mxs_json_pointer(json, MXS_JSON_PTR_PARAMETERS)) + { + const char* key; + json_t* value; + + json_object_foreach(parameters, key, value) + { + if (json_is_string(value) && strchr(json_string_value(value), '\n')) + { + config_runtime_error("Parameter '%s' contains unescaped newlines", key); + return false; + } + } + } + if (!(value = mxs_json_pointer(json, MXS_JSON_PTR_ID))) { config_runtime_error("Value not found: '%s'", MXS_JSON_PTR_ID);