From 75c6ef2dc8189a1492d76cc205fdcc21f660929d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20M=C3=A4kel=C3=A4?= Date: Fri, 22 Mar 2019 12:52:56 +0200 Subject: [PATCH] Fix mxs_json_error usage The function takes printf style arguments which means the format string must be a string constant. --- server/core/json_api.cc | 2 +- server/core/resource.cc | 12 ++++-------- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/server/core/json_api.cc b/server/core/json_api.cc index f6f3c2d2b..93d9295a7 100644 --- a/server/core/json_api.cc +++ b/server/core/json_api.cc @@ -218,7 +218,7 @@ json_t* mxs_json_error(const std::vector& errors) for (it = std::next(it); it != errors.end(); ++it) { - rval = mxs_json_error_append(rval, it->c_str()); + rval = mxs_json_error_append(rval, "%s", it->c_str()); } } diff --git a/server/core/resource.cc b/server/core/resource.cc index 1b67c23bd..0178a8899 100644 --- a/server/core/resource.cc +++ b/server/core/resource.cc @@ -786,14 +786,12 @@ HttpResponse cb_set_server(const HttpRequest& request) } else { - return HttpResponse(MHD_HTTP_FORBIDDEN, mxs_json_error(errmsg.c_str())); + return HttpResponse(MHD_HTTP_FORBIDDEN, mxs_json_error("%s", errmsg.c_str())); } } return HttpResponse(MHD_HTTP_FORBIDDEN, - mxs_json_error("Invalid or missing value for the `%s` " - "parameter", - CN_STATE)); + mxs_json_error("Invalid or missing value for the `%s` parameter", CN_STATE)); } HttpResponse cb_clear_server(const HttpRequest& request) @@ -810,14 +808,12 @@ HttpResponse cb_clear_server(const HttpRequest& request) } else { - return HttpResponse(MHD_HTTP_FORBIDDEN, mxs_json_error(errmsg.c_str())); + return HttpResponse(MHD_HTTP_FORBIDDEN, mxs_json_error("%s", errmsg.c_str())); } } return HttpResponse(MHD_HTTP_FORBIDDEN, - mxs_json_error("Invalid or missing value for the `%s` " - "parameter", - CN_STATE)); + mxs_json_error("Invalid or missing value for the `%s` parameter", CN_STATE)); } HttpResponse cb_modulecmd(const HttpRequest& request)