mirror of https://github.com/meshcore-dev/MeshCore
Browse Source
The buffer-full branch writes the forced '\r' to command[sizeof-1], but the line-complete check below tests command[len-1] (== sizeof-2 when the buffer is full), so the line never completes: the read loop's condition (len < sizeof-1) stays false forever and the CLI stops reading serial input until reboot. Writing at [sizeof-1] also overwrites the string's NUL terminator, so the next strlen() reads past the buffer (UB). Write the '\r' at command[sizeof-2] instead — exactly the position the completion check tests. The overflowed input is then processed as an (unknown) command, the buffer resets, and the CLI keeps working. Reproduced on hardware (T1000-E repeater): ~53 arrow-key presses in an attached terminal (3-byte ESC[A escape sequences, 159 bytes with no CR) filled the buffer and the CLI never accepted a command again until reboot. The same copy-pasted pattern is fixed in simple_repeater, simple_sensor, simple_room_server and simple_secure_chat.pull/2978/head
4 changed files with 4 additions and 4 deletions
Loading…
Reference in new issue