This PR is based around treating uopt->presetSlot consistently as a character rather than integer index. This approach requires the least changes to code, since it requires no changes to the web UI sending ASCII, and most (but not all) of the C++ backend already treats uopt->presetSlot as ASCII. Alternative approaches are also possible (see #422 @ Solutions), but are more difficult and may introduce errors due to making large untested changes, so I don't want to pursue them.
Fix settings all appearing as disabled after factory reset
Highlight first slot after factory reset, rather than null slot
Add checks for invalid preset IDs/numbers in HTTP handlers
This fixes possibly-exploitable memory corruption bugs. There are likely more yet to be fixed, for example #421 (thanks C++ and no bounds checks).
Add Ascii8 type for uopt->presetSlot, so we don't treat it as a number
Should this instead be marked as char?
Or do you want to leave it as uint8_t, and not encode "preset slots are ASCII" through the variable's type?
Remove incorrect "bounds checks" for ASCII character in uopt->presetSlot
This PR is based around treating
uopt->presetSlot
consistently as a character rather than integer index. This approach requires the least changes to code, since it requires no changes to the web UI sending ASCII, and most (but not all) of the C++ backend already treatsuopt->presetSlot
as ASCII. Alternative approaches are also possible (see #422 @ Solutions), but are more difficult and may introduce errors due to making large untested changes, so I don't want to pursue them.uopt->presetSlot
, so we don't treat it as a numberchar
?uint8_t
, and not encode "preset slots are ASCII" through the variable's type?uopt->presetSlot
Fixes #422.