Skip to content

Commit

Permalink
Fix DataModelLogger::LogAttribute for unknown attributes. (#14775)
Browse files Browse the repository at this point in the history
LogAttribute was missing break statements in its switches, so trying
to read an attribute that controller-clusters does not have enabled
(e.g. UniqueID from Bridged Device Basic Information) would start
falling through to other clusters and possibly trying to treat it as
another attribute that happens to have the same attribute id (in this
case the Primary1Y attribute from Color Control).

Then TLV decoding would fail due to type mismatch errors, which is not
what we want here.
  • Loading branch information
bzbarsky-apple authored Feb 4, 2022
1 parent a5920db commit 5f7fe7f
Show file tree
Hide file tree
Showing 2 changed files with 117 additions and 6 deletions.
15 changes: 12 additions & 3 deletions examples/chip-tool/templates/logging/DataModelLogger-src.zapt
Original file line number Diff line number Diff line change
Expand Up @@ -83,13 +83,16 @@ CHIP_ERROR DataModelLogger::LogAttribute(const chip::app::ConcreteDataAttributeP
}
{{#last}}
}
break;
}
{{/last}}
{{/chip_server_cluster_attributes}}
{{/chip_client_clusters}}
default:
return CHIP_NO_ERROR;
break;
}
ChipLogProgress(chipTool, " Don't know how to log atribute value");
return CHIP_NO_ERROR;
}

CHIP_ERROR DataModelLogger::LogCommand(const chip::app::ConcreteCommandPath & path, chip::TLV::TLVReader * data)
Expand All @@ -115,13 +118,16 @@ CHIP_ERROR DataModelLogger::LogCommand(const chip::app::ConcreteCommandPath & pa
}
{{#last}}
}
break;
}
{{/last}}
{{/chip_cluster_responses}}
{{/chip_client_clusters}}
default:
return CHIP_NO_ERROR;
break;
}
ChipLogProgress(chipTool, " Don't know how to log command response data");
return CHIP_NO_ERROR;
}

CHIP_ERROR DataModelLogger::LogEvent(const chip::app::EventHeader & header, chip::TLV::TLVReader * data)
Expand Down Expand Up @@ -168,11 +174,14 @@ CHIP_ERROR DataModelLogger::LogEvent(const chip::app::EventHeader & header, chip
}
{{#last}}
}
break;
}
{{/last}}
{{/chip_server_cluster_events}}
{{/chip_client_clusters}}
default:
return CHIP_NO_ERROR;
break;
}
ChipLogProgress(chipTool, " Don't know how to log event data");
return CHIP_NO_ERROR;
}
Loading

0 comments on commit 5f7fe7f

Please sign in to comment.