-
Notifications
You must be signed in to change notification settings - Fork 8k
Labels
area: NetworkingbugThe issue is a bug, or the PR is fixing a bugThe issue is a bug, or the PR is fixing a bugpriority: mediumMedium impact/importance bugMedium impact/importance bug
Description
Describe the bug
Using the CoAP client to make a request using a path
located for example on the stack, it is later used to evaluate matching requests.
Consider the following snippets:
static int foo_get(uint16_t id)
{
/* Construct my dynamic path */
char path[sizeof("foo/xxxxx")];
snprintf(path, sizeof(path), "foo/%d", id);
/* Do request */
struct coap_client_request req = {
.method = COAP_METHOD_GET,
.path = path, /* <--------- A stack buffer */
.cb = foo_cb,
};
/* Doing the request is fine because the CoAP packet is constructed
* and the path is converted to CoAP options */
return coap_client_req(&client, 0, &dst_address, &req, NULL));
}
If at any point in the lifetime of the request a call is done to coap_client_cancel_request
or coap_client_cancel_requests
it will compare an internally stored copy of the pointer here:
zephyr/subsys/net/lib/coap/coap_client.c
Lines 1064 to 1066 in 491498a
if (a->path && b->path && strcmp(a->path, b->path) != 0) { | |
return false; | |
} |
Resulting in calling strcmp
with an invalid pointer.
Regression
- This is a regression.
Steps to reproduce
No response
Relevant log output
Impact
Functional Limitation – Some features not working as expected, but system usable.
Environment
No response
Additional Context
No response
Metadata
Metadata
Labels
area: NetworkingbugThe issue is a bug, or the PR is fixing a bugThe issue is a bug, or the PR is fixing a bugpriority: mediumMedium impact/importance bugMedium impact/importance bug