mirror of
https://github.com/espressif/openthread.git
synced 2026-08-02 00:57:47 +00:00
[dua-manager] avoid null dereference in CoAP response handler (#6509)
This commit changes `DuaManager::HandleDuaResponse()` to use a pointer to `aMessage` and `aMessageInfo` (instead of reference) Note that in case of a failure, the `Coap` module may invoke the response handler with `nullptr` for these parameters.
This commit is contained in:
@@ -538,7 +538,7 @@ exit:
|
||||
otLogInfoDua("Sent DUA.req for DUA %s: %s", dua.ToString().AsCString(), ErrorToString(error));
|
||||
}
|
||||
|
||||
void DuaManager::HandleDuaResponse(Coap::Message &aMessage, const Ip6::MessageInfo &aMessageInfo, Error aResult)
|
||||
void DuaManager::HandleDuaResponse(Coap::Message *aMessage, const Ip6::MessageInfo *aMessageInfo, Error aResult)
|
||||
{
|
||||
OT_UNUSED_VARIABLE(aMessageInfo);
|
||||
Error error;
|
||||
@@ -552,10 +552,12 @@ void DuaManager::HandleDuaResponse(Coap::Message &aMessage, const Ip6::MessageIn
|
||||
}
|
||||
|
||||
VerifyOrExit(aResult == kErrorNone, error = kErrorParse);
|
||||
VerifyOrExit(aMessage.GetCode() == Coap::kCodeChanged || aMessage.GetCode() >= Coap::kCodeBadRequest,
|
||||
OT_ASSERT(aMessage != nullptr);
|
||||
|
||||
VerifyOrExit(aMessage->GetCode() == Coap::kCodeChanged || aMessage->GetCode() >= Coap::kCodeBadRequest,
|
||||
error = kErrorParse);
|
||||
|
||||
error = ProcessDuaResponse(aMessage);
|
||||
error = ProcessDuaResponse(*aMessage);
|
||||
|
||||
exit:
|
||||
if (error != kErrorResponseTimeout)
|
||||
|
||||
@@ -201,10 +201,10 @@ private:
|
||||
static void HandleDuaResponse(void *aContext, otMessage *aMessage, const otMessageInfo *aMessageInfo, Error aResult)
|
||||
{
|
||||
static_cast<DuaManager *>(aContext)->HandleDuaResponse(
|
||||
*static_cast<Coap::Message *>(aMessage), *static_cast<const Ip6::MessageInfo *>(aMessageInfo), aResult);
|
||||
static_cast<Coap::Message *>(aMessage), static_cast<const Ip6::MessageInfo *>(aMessageInfo), aResult);
|
||||
}
|
||||
|
||||
void HandleDuaResponse(Coap::Message &aMessage, const Ip6::MessageInfo &aMessageInfo, Error aResult);
|
||||
void HandleDuaResponse(Coap::Message *aMessage, const Ip6::MessageInfo *aMessageInfo, Error aResult);
|
||||
|
||||
static void HandleDuaNotification(void *aContext, otMessage *aMessage, const otMessageInfo *aMessageInfo)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user