Skip to content

Commit 5105db3

Browse files
Append terminating char to received string for config updates
1 parent 135f087 commit 5105db3

File tree

1 file changed

+3
-1
lines changed
  • tmk_core/protocol/nrf

1 file changed

+3
-1
lines changed

tmk_core/protocol/nrf/bmp.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -456,8 +456,9 @@ int stream_write_callback(const uint8_t* dat, uint32_t len)
456456
dst = parser.setting->string_dst;
457457
dst_len = parser.setting->dst_len;
458458

459-
if (parser.write_idx + len > dst_len)
459+
if (parser.write_idx + len + 1 > dst_len)
460460
{
461+
// buffer overflow
461462
parser.write_idx = 0;
462463
set_parser(PARSER_NONE);
463464

@@ -472,6 +473,7 @@ int stream_write_callback(const uint8_t* dat, uint32_t len)
472473
json_close = is_json_closed((const char*)dst, parser.write_idx);
473474
if (json_close == 0)
474475
{
476+
dst[parser.write_idx] = '\0';
475477
int res = parser.setting->parse();
476478
parser.write_idx = 0;
477479
BMPAPI->logger.info("Received json");

0 commit comments

Comments
 (0)