json: fix buffer overrun in encoding helper

The bounds check failed to account for the additional space required
for the terminating NUL after the encoded value was written.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
This commit is contained in:
Peter Bigot 2020-04-21 14:56:52 -05:00 committed by Anas Nashif
commit a09f6ad54c
2 changed files with 23 additions and 2 deletions

View file

@ -875,7 +875,7 @@ static int append_bytes_to_buf(const char *bytes, size_t len, void *data)
{
struct appender *appender = data;
if (len > appender->size - appender->used) {
if (len >= appender->size - appender->used) {
return -ENOMEM;
}