net: lib: coap: fix path and query options init

Fix options initialization for path and query
when a final segment is one character long.

For example, "a/b" inits path as ["a"] instead
of expected ["a", "b"]. The same applies to
query option. The "a/abc?a&b"  options won't
contain "b".

Signed-off-by: Georgij Cernysiov <geo.cgv@gmail.com>
This commit is contained in:
Georgij Cernysiov 2023-08-24 09:24:34 +02:00 committed by Carles Cufí
parent 7a2e86f563
commit afbfdc5bd7

View file

@ -198,7 +198,7 @@ static int coap_client_init_path_options(struct coap_packet *pckt, const char *p
}
}
if (path_start < path_end) {
if (path_start < path_length) {
if (contains_query) {
ret = coap_packet_append_option(pckt, COAP_OPTION_URI_QUERY,
path + path_start,