net: lwm2m: json: fix potential buffer overflow

Use the size of the target buffer as the maximum length when
formatting with snprintf.

See https://habr.com/en/company/pvs-studio/blog/495284/ fragment 3.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
This commit is contained in:
Peter Bigot 2020-04-05 11:10:39 -05:00 committed by Anas Nashif
commit 687826e83e

View file

@ -823,7 +823,7 @@ int do_write_op_json(struct lwm2m_message *msg)
}
/* combine base_name + name */
snprintf(full_name, TOKEN_BUF_LEN, "%s%s",
snprintf(full_name, sizeof(full_name), "%s%s",
base_name, value);
/* parse full_name into path */