net: lwm2m: fix empty path being treated as 0/0/0 issue
Return 4.05 Method Not Allowed when path is empty ('/') to the caller for it's only use by bootstrap delete. This change also avoid the empty path being treated as request targeted at 0/0/0. Signed-off-by: Robert Chou <robert.ch.chou@acer.com>
This commit is contained in:
parent
ce5e0d7208
commit
d5ab14697f
1 changed files with 17 additions and 11 deletions
|
@ -2290,17 +2290,23 @@ static int handle_request(struct zoap_packet *request,
|
|||
|
||||
/* parse the URL path into components */
|
||||
r = zoap_find_options(in.in_zpkt, ZOAP_OPTION_URI_PATH, options, 4);
|
||||
if (r > 0) {
|
||||
/* check for .well-known/core URI query (DISCOVER) */
|
||||
if (r == 2 &&
|
||||
(options[0].len == 11 &&
|
||||
strncmp(options[0].value, ".well-known", 11) == 0) &&
|
||||
(options[1].len == 4 &&
|
||||
strncmp(options[1].value, "core", 4) == 0)) {
|
||||
discover = true;
|
||||
} else {
|
||||
zoap_options_to_path(options, r, &path);
|
||||
}
|
||||
if (r <= 0) {
|
||||
/* '/' is used by bootstrap-delete only */
|
||||
|
||||
/* TODO: handle bootstrap-delete */
|
||||
r = -EPERM;
|
||||
goto error;
|
||||
}
|
||||
|
||||
/* check for .well-known/core URI query (DISCOVER) */
|
||||
if (r == 2 &&
|
||||
(options[0].len == 11 &&
|
||||
strncmp(options[0].value, ".well-known", 11) == 0) &&
|
||||
(options[1].len == 4 &&
|
||||
strncmp(options[1].value, "core", 4) == 0)) {
|
||||
discover = true;
|
||||
} else {
|
||||
zoap_options_to_path(options, r, &path);
|
||||
}
|
||||
|
||||
/* read Content Format */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue