ThingSet / thingset-device-library

ThingSet library for resource-constrained devices written in C/C++
https://thingset.io/thingset-device-library/
Apache License 2.0
14 stars 6 forks source link

Fix string length check in txt_patch function #26

Closed martinjaeger closed 2 years ago

martinjaeger commented 2 years ago

The previous implementation tried to copy a JSON string value into the small temporary buffer of 21 bytes if the string was short enough to fit into the actual data object buffer. The resulted in a buffer overflow.

In addition to that, it's not necessary to copy the string to check if the buffer is large enough.

This commit fixes the string data object check and avoids the buffer overflow.