summaryrefslogtreecommitdiff
path: root/http
diff options
context:
space:
mode:
authorJonathan Doman <jonathan.doman@intel.com>2023-03-22 04:17:06 +0300
committerEd Tanous <ed@tanous.net>2023-03-22 18:50:38 +0300
commitd3c8ce63ce13b2094b01f7c9eb8be4d3d5daa52f (patch)
tree47703fb6d4247caff8356f783a3988ae8a0799ed /http
parentf574a8e1e6d50e285a3808959acc7d21297b94b6 (diff)
downloadbmcweb-d3c8ce63ce13b2094b01f7c9eb8be4d3d5daa52f.tar.xz
Fix Request use-after-move
Partial revert of 915d2d4e59be56958b04a79ba96e0242ef735f44 Request object was being moved out of the owning Connection object, which would then try to use the Request again in completeRequest(). Just pass around a reference instead of taking ownership. The obvious symptom was that Redfish pages were served as json in the browser instead of HTML, because the headers in the Request were no longer valid after being moved. Tested: /redfish/v1 is served as HTML in the browser again. Change-Id: Iae68a68817146c28377bbcade04716725e4a6096 Signed-off-by: Jonathan Doman <jonathan.doman@intel.com>
Diffstat (limited to 'http')
-rw-r--r--http/routing.hpp21
1 files changed, 10 insertions, 11 deletions
diff --git a/http/routing.hpp b/http/routing.hpp
index 5bf6c902ca..e41ce936f8 100644
--- a/http/routing.hpp
+++ b/http/routing.hpp
@@ -1335,7 +1335,7 @@ class Router
}
template <typename CallbackFn>
- void afterGetUserInfo(Request&& req,
+ void afterGetUserInfo(Request& req,
const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
BaseRule& rule, CallbackFn&& callback,
const boost::system::error_code& ec,
@@ -1356,11 +1356,11 @@ class Router
asyncResp->res.result(boost::beast::http::status::forbidden);
return;
}
- callback(std::move(req));
+ callback(req);
}
template <typename CallbackFn>
- void validatePrivilege(Request&& req,
+ void validatePrivilege(Request& req,
const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
BaseRule& rule, CallbackFn&& callback)
{
@@ -1370,11 +1370,11 @@ class Router
}
std::string username = req.session->username;
crow::connections::systemBus->async_method_call(
- [this, req{std::move(req)}, asyncResp, &rule,
+ [this, &req, asyncResp, &rule,
callback(std::forward<CallbackFn>(callback))](
const boost::system::error_code& ec,
const dbus::utility::DBusPropertiesMap& userInfoMap) mutable {
- afterGetUserInfo(std::move(req), asyncResp, rule,
+ afterGetUserInfo(req, asyncResp, rule,
std::forward<CallbackFn>(callback), ec,
userInfoMap);
},
@@ -1431,9 +1431,9 @@ class Router
// TODO(ed) This should be able to use std::bind_front, but it doesn't
// appear to work with the std::move on adaptor.
validatePrivilege(
- std::move(req), asyncResp, rule,
+ req, asyncResp, rule,
[&rule, asyncResp, adaptor(std::forward<Adaptor>(adaptor))](
- Request&& thisReq) mutable {
+ Request& thisReq) mutable {
rule.handleUpgrade(thisReq, asyncResp, std::move(adaptor));
});
}
@@ -1503,11 +1503,10 @@ class Router
rule.handle(req, asyncResp, params);
return;
}
- validatePrivilege(
- std::move(req), asyncResp, rule,
- [&rule, asyncResp, params](Request&& thisReq) mutable {
+ validatePrivilege(req, asyncResp, rule,
+ [&rule, asyncResp, params](Request& thisReq) mutable {
rule.handle(thisReq, asyncResp, params);
- });
+ });
}
void debugPrint()