From d3a1f53647131ae12c2a2328e6569ef5672ddc2e Mon Sep 17 00:00:00 2001 From: Michael Friedrich Date: Wed, 1 Mar 2017 11:33:43 +0100 Subject: [PATCH] API: Fix error code for invalid 'attrs' type for POST requests fixes #5043 --- lib/remote/modifyobjecthandler.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/remote/modifyobjecthandler.cpp b/lib/remote/modifyobjecthandler.cpp index 3a43b2ff5..1b17a290a 100644 --- a/lib/remote/modifyobjecthandler.cpp +++ b/lib/remote/modifyobjecthandler.cpp @@ -68,7 +68,15 @@ bool ModifyObjectHandler::HandleRequest(const ApiUser::Ptr& user, HttpRequest& r return true; } - Dictionary::Ptr attrs = params->Get("attrs"); + Value attrsVal = params->Get("attrs"); + + if (attrsVal.GetReflectionType() != Dictionary::TypeInstance) { + HttpUtility::SendJsonError(response, 400, + "Invalid type for 'attrs' attribute specified. Dictionary type is required.", Empty); + return true; + } + + Dictionary::Ptr attrs = attrsVal; Array::Ptr results = new Array();