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:
parent
315cba1c40
commit
a09f6ad54c
2 changed files with 23 additions and 2 deletions
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue