Fix SetStatusDelimiter: stack over-read and pointer-sign warnings #1
Reference in New Issue
Block a user
Delete Branch "fix/status-delimiter-1.2"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Two fixes to
YEEP144lib/src/YEEP144_BluetoothUART.c, against the 1.2 release.Both are pre-existing issues that 1.2 does not address. 7 insertions, 3 deletions, one file.
Fix 1 —
SetStatusDelimiter()over-reads a stack bufferrxBufis a different, unrelated buffer declared earlier in the same function, so this transmits 10 bytes from an 8-byte array — a two-byte stack over-read, and two bytes of stack garbage follow everySOcommand the module receives.Fixed by sending
strlen(txBuf), which stops at the NUL thatsprintf()wrote.sizeof(txBuf)would also stop the over-read but would still transmit the padding NULs.Since 1.2 no longer calls this function from
Init(), it is only reachable if an application calls it directly — but it is a public API function, and the over-read is undefined behaviour either way.Fix 2 — three
-Wpointer-signwarningsHAL_UART_Transmit()takesconst uint8_t *; the function passeschar *at three sites. Casts added, and the file now compiles warning-free. These warnings sit on the same lines as Fix 1, which is part of why the over-read went unnoticed.Not included — already fixed by 1.2
An earlier report covered
BluetoothUART_Init()entering the module's command mode and rebooting the RN4678 on every boot. 1.2 removes that call fromInit(), so nothing is needed here. A suggested follow-up is recorded inCODE_FIXES.md: expose the configuration as an explicitConfigureModule()rather than as a side effect of startup.Full write-up
CODE_FIXES.md
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.