mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
Merge #19994
19994: nanocoap: prevent integer underflow in coap_opt_put_uri_pathquery() r=miri64 a=benpicco Co-authored-by: Benjamin Valentin <benjamin.valentin@ml-pa.com>
This commit is contained in:
commit
61ae692ae9
@ -902,8 +902,15 @@ size_t coap_opt_put_string_with_len(uint8_t *buf, uint16_t lastonum, uint16_t op
|
||||
|
||||
size_t coap_opt_put_uri_pathquery(uint8_t *buf, uint16_t *lastonum, const char *uri)
|
||||
{
|
||||
size_t len;
|
||||
const char *query = strchr(uri, '?');
|
||||
size_t len = query ? (size_t)(query - uri - 1) : strlen(uri);
|
||||
|
||||
if (query) {
|
||||
len = (query == uri) ? 0 : (query - uri - 1);
|
||||
} else {
|
||||
len = strlen(uri);
|
||||
}
|
||||
|
||||
size_t bytes_out = coap_opt_put_string_with_len(buf, *lastonum,
|
||||
COAP_OPT_URI_PATH,
|
||||
uri, len, '/');
|
||||
|
Loading…
Reference in New Issue
Block a user