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:
Robert Chou 2017-08-28 14:54:40 +08:00 committed by Anas Nashif
commit d5ab14697f

View file

@ -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 */