Repository navigation
fix(core): skip null entries in shocker command lists #596
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| --- | ||
| kind: security | ||
| --- | ||
| Skip null entries in a shocker command list instead of crashing | ||
|
|
||
| ## Release Note | ||
| Malformed shocker commands no longer crash the hub | ||
|
|
||
| A command list with an empty entry, sent over the setup portal or the gateway connection, is now skipped instead of crashing the hub. | ||
|
|
||
| - The FlatBuffers verifier accepts a zero offset in a vector of tables, so each entry is now checked before it is read | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -57,6 +57,12 @@ void OpenShock::MessageHandlers::HandleShockerCommandList(const OpenShock::Seria | |
| OS_LOGV(TAG, "Received command list (%u commands)", static_cast<unsigned>(commands->size())); | ||
|
|
||
| for (auto command : *commands) { | ||
| // The verifier accepts a zero offset in a vector of tables, so an entry can be null | ||
| if (command == nullptr) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The null check never catches a zero offset. The iterator returns the address of the offset slot for a zero offset, not Detect zero-offset entries before dereferencing them. Log and skip those entries, then continue with the remaining commands. Keep the existing handling for non-null entries unchanged.
|
||
| OS_LOGE(TAG, "Received null command in command list"); | ||
| continue; | ||
| } | ||
|
|
||
| uint16_t id = command->id(); | ||
| uint8_t intensity = command->intensity(); | ||
| uint16_t durationMs = command->duration(); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Describe the entry-level skip.
The handler skips the empty entry, not the whole list. Valid entries in the same list continue to be processed. Update the note to make that distinction.