forked from project-chip/connectedhomeip
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ensure all fields in cluster-objects structs are default-initialized.
Otherwise we can end up reading random values from un-initialized memory (e.g. if a mandatory command/struct/event field is not sent by the other side). Fixes project-chip#10271
- Loading branch information
1 parent
1cbec52
commit 2087c91
Showing
6 changed files
with
2,420 additions
and
2,352 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
17 changes: 17 additions & 0 deletions
17
src/app/zap-templates/partials/cluster-objects-field-init.zapt
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{{! For now, just initialize fields to type defaults. Longer-term, we | ||
may want to use spec-defined default values here. }} | ||
{{#unless isOptional}} {{! Optionals inited by constructor }} | ||
{{~#unless isNullable}} {{! Nullables inited by constructor }} | ||
{{~#unless isArray}} {{! DataModel lists inited by constructor }} | ||
{{~#unless entryType}} {{! DataModel lists (for attributes) inited by constructor }} | ||
{{~#unless (isString type)}} {{! Strings are Spans, inited by constructor }} | ||
{{~#if_is_struct type}} | ||
{{! Structs have their own initializers }} | ||
{{~else~}} | ||
= static_cast<{{zapTypeToEncodableClusterObjectType type}}>(0) | ||
{{~/if_is_struct}} | ||
{{~/unless}} | ||
{{~/unless}} | ||
{{~/unless}} | ||
{{~/unless}} | ||
{{~/unless}} |
This file contains 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
Oops, something went wrong.