diff options
author | Lei YU <yulei.sh@bytedance.com> | 2023-03-17 08:17:05 +0300 |
---|---|---|
committer | Lei YU <yulei.sh@bytedance.com> | 2023-03-17 08:48:06 +0300 |
commit | 28dd5ca15a3008e50e5046602464966720d6b5f3 (patch) | |
tree | 35450188f069e1f164ef55fc32e160ca210d14de /Redfish.md | |
parent | f5892d0d56accc51deb5e4ad1bbdad6028784c16 (diff) | |
download | bmcweb-28dd5ca15a3008e50e5046602464966720d6b5f3.tar.xz |
dbus_rest: Fix dangling reference of crow::Response
The openbmc_dbus_reset was holding reference of `crow::Response`, set
the response in `~InProgressActionData()`, and call res.end() to
complete the result of the response.
The bmcweb code now uses `std::shared_ptr<AsyncResp>` for the response
and the `res.end()` is handled in `~AsyncResp()`.
By using the reference of `crow::Response`, the `InProgressActionData`
is actually using a dangling reference because the
`std::shared_ptr<AsyncResp>` is already destructed, and bmcweb will
crash on `action` calls, or not crash but get invalid response, as it's
undefined behavior.
Fix the above issue by using `std::shared_ptr<AsyncResp>` to make sure
the response is correctly handled.
Tested:
1. Without the fix, bmcweb crashes, or get no json output response on
the below method call, be noted that it's an invalid call:
```
$ curl -k -H "X-Auth-Token: $token" -x POST -d '{"data": []}' https://${bmc}/xyz/openbmc_project/logging/action/deleteAll
```
2. With the fix, bmcweb gives expected response:
```
$ curl -k -H "X-Auth-Token: $token" -x POST -d '{"data": []}' https://${bmc}/xyz/openbmc_project/logging/action/deleteAll
{
"data": {
"description": "The specified method cannot be found"
},
"message": "404 Not Found",
"status": "error"
}
$ curl -k -H "X-Auth-Token: $token" -x POST -d '{"data": []}' https://${bmc}/xyz/openbmc_project/logging/action/DeleteAll
{
"data": null,
"message": "200 OK",
"status": "ok"
}
```
Signed-off-by: Lei YU <yulei.sh@bytedance.com>
Change-Id: I38ef34fe8ff18e4e127664c853c6792461f6edf8
Diffstat (limited to 'Redfish.md')
0 files changed, 0 insertions, 0 deletions