Skip to content
Snippets Groups Projects
Commit becfce24 authored by Hauke Petersen's avatar Hauke Petersen
Browse files

net/nanocoap: allow empty uri/location path option

For CoAP, there is actually a difference between
`/some/path` and `/some/path/`. This needs to be reflected
when parsing the URI and location path options from a given
string.
parent 6265da28
Branches
No related tags found
No related merge requests found
......@@ -603,7 +603,9 @@ size_t coap_opt_put_string(uint8_t *buf, uint16_t lastonum, uint16_t optnum,
part_len = (uint8_t *)uripos - part_start;
if (part_len) {
/* Creates empty option if part for Uri-Path or Uri-Location contains only *
* a trailing slash, except for root path ("/"). */
if (part_len || ((separator == '/') && (lastonum == optnum))) {
bufpos += coap_put_option(bufpos, lastonum, optnum, part_start, part_len);
lastonum = optnum;
}
......@@ -658,7 +660,9 @@ ssize_t coap_opt_add_string(coap_pkt_t *pkt, uint16_t optnum, const char *string
part_len = (uint8_t *)uripos - part_start;
if (part_len) {
/* Creates empty option if part for Uri-Path or Uri-Location contains
* only a trailing slash, except for root path ("/"). */
if (part_len || ((separator == '/') && write_len)) {
if (pkt->options_len == NANOCOAP_NOPTS_MAX) {
return -ENOSPC;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment