net: lwm2m: Fix msg find based on pending/reply
The message should only be returned if the requested pending/reply pointer is not NULL. Otherwise it could get an incorrect match (for instance if specific pending pointer is searched for and reply is NULL the function could return any message that doesn't expect a reply (and thus has its reply pointer set to NULL). Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
This commit is contained in:
parent
4331c05f17
commit
7eefde36c3
1 changed files with 4 additions and 2 deletions
|
@ -869,11 +869,13 @@ static struct lwm2m_message *find_msg(struct coap_pending *pending,
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < CONFIG_LWM2M_ENGINE_MAX_MESSAGES; i++) {
|
for (i = 0; i < CONFIG_LWM2M_ENGINE_MAX_MESSAGES; i++) {
|
||||||
if (messages[i].ctx && messages[i].pending == pending) {
|
if (pending != NULL && messages[i].ctx &&
|
||||||
|
messages[i].pending == pending) {
|
||||||
return &messages[i];
|
return &messages[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (messages[i].ctx && messages[i].reply == reply) {
|
if (reply != NULL && messages[i].ctx &&
|
||||||
|
messages[i].reply == reply) {
|
||||||
return &messages[i];
|
return &messages[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue