Repository navigation
fix: companion text CLI refuses NaN tz, checks pin range, bounds board copy (13d-c) - #53
Merged
marcelverdult merged 6 commits intoNov 10, 2026
Conversation
atof("nan") is NaN, so tz < -12 || tz > 14 was false and the value was
stored. The check now reads !(tz >= -12 && tz <= 14). Every value that was
valid or refused before behaves the same. The test that pinned NaN as
accepted now asserts the refusal, no save and an unchanged offset.
The pin must be 0 or 100000 to 999999, the rule of the app's cmdSetDevicePin(). Anything else answers 'Error, pin must be 0 or 6 digits' and stores and saves nothing. The number is read into a long and checked before it goes into the unsigned field, so negative and very large numbers are refused. Text without a leading number still reads as 0 and is accepted as pin 0, as with atoi(). The tests that pinned the missing check now assert the range.
strcpy() of the manufacturer name into the reply buffer is now a copy of at most 39 characters, like the 40 byte name in the app's device info frame. The smallest caller buffer is 161 bytes. The longest board name in the tree has 37 characters, so no real board answers differently. MockBoard gets a settable name; new tests cover a name at the limit, a name over it and the guard bytes behind the reply buffer.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Step 13d-c of the refactoring series. After the harness (13d-a) and the tables (13d-b), this is the first step of the series that changes behaviour. It corrects three things in the companion's text CLI that the 13d-a tests had pinned as they were, each in its own commit and in one handler.
Behaviour changes
set tz.offset nanNaNis false in both comparisons oftz < -12 || tz > 14Error, must be from -12 to +14, nothing saved. Every other value answers as before.set pin <n>atoi(), any number accepted and stored in the unsignedble_pincmdSetDevicePin()of the app frame already has. Anything else answersError, pin must be 0 or 6 digits, nothing saved. A five digit PIN, which worked before, is now refused. Text without a leading number still reads as 0 and is accepted, as withatoi().boardstrcpy()ofboard.getManufacturerName()into the replyStrHelper::strncpywith 40). The smallest reply buffer of the callers is 161 bytes (remote CLI). All 76 board names written as string literals in the tree are 37 characters or less (longest:Ikoka Handheld E22 30dBm (Xiao_nrf52)), so their reply is byte for byte the same.What is in it
set pintests are rewritten and a third uses 100000 instead of 12, and two newboardtests check a name at and above the limit with the guard bytes behind the reply buffer.MockBoard::manufacturercan be set for that and is reset inreset().docs/refactoring/0013-cli-command-table.md(each change as before and after, the limits that were tested, mutation table, size) and the README row for step 13.Verification
run-unit-tests.yml: 2445 cases, 1 skipped, 2444 passed (13d-b: 2435; the 10 new cases are the twoboardtests in each of the five companion environments). The five companion environments have 125, 130, 146, 140 and 170 cases.strcpy(), a limit that is too large or too small. Three of them were rerun on the final branch (tzupper bound 14 to 15, PIN upper bound 999999 to 9999999,boardlimit 40 to 20) and turned 1, 1 and 2 tests red.RAK_4631_companion_radio_ble: flash 473976 before, 474088 after (+112 bytes), RAM unchanged at 149928.Not verified
NaNdid on a board before this change, and how the BLE stack handles a PIN outside the range, was not measured.set pinwith fewer than six digits was not checked.getManufacturerName()that are not string literals were read by hand in the session; the check of the literals was repeated on the final branch.Left as it is
get wifi.pwdstill answers the WiFi password in clear text, also to a contact with the remote CLI flag. Whether the apps use the command was not checked, so this stays an open point in the note.checkCLIRescueCmd()have no tests and are not changed.