Commit b528231
backup: read board vendor/model from the right cJSON nodes (#182)
do_upgrade() looked up the "vendor" and "model" items of the board info
object, then called cJSON_GetStringValue(binfo) on the *object* instead of
on the item it had just found. cJSON_GetStringValue() returns NULL for a
non-string, so:
- the vendor branch was NULL-guarded and silently did nothing;
- the model branch was not, and ran strcpy(board_id, NULL).
So `ipctool upgrade` segfaults on any board whose detector supplies a
"model" key — currently Ruision, Anjoy and Hankvision (src/boards/*.c) — and
on every other board it leaves board_id empty, so the "hardware" U-Boot
variable set from it further down never gets written.
Read the values from c_vendor/c_model, guard both against NULL, and bound
the copies with snprintf: the strings come from board detection (sysinfo
files, directory names) and were being strcpy/strcat'ed into fixed 1024-byte
buffers unchecked.
Behaviour is otherwise preserved, including board_id carrying the model
alone.
Note: `board` is assembled here but never read afterwards. That is
pre-existing, so left alone rather than silently changing what the composed
string is meant to be.
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>1 parent 1bead33 commit b528231
1 file changed
Lines changed: 10 additions & 12 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
880 | 880 | | |
881 | 881 | | |
882 | 882 | | |
883 | | - | |
884 | | - | |
885 | | - | |
886 | | - | |
887 | | - | |
888 | | - | |
889 | | - | |
890 | | - | |
891 | | - | |
892 | | - | |
893 | | - | |
894 | | - | |
| 883 | + | |
| 884 | + | |
| 885 | + | |
| 886 | + | |
| 887 | + | |
| 888 | + | |
| 889 | + | |
| 890 | + | |
| 891 | + | |
| 892 | + | |
895 | 893 | | |
896 | 894 | | |
897 | 895 | | |
| |||
0 commit comments