Skip to content

Commit

Permalink
Fix the missing commandList container closure in IM command (project-…
Browse files Browse the repository at this point in the history
…chip#5799)

Problem:
src/app/Command.h and .cpp create incomplete tlv data, the commandList array is missing the end of container byte

Calling Command::Init() followed by Command::FinalizeCommandsMessage() results in following invalid tlv data:

15 36 00 18

It should be: 15 36 00 18 18

This affects every interactive model command, they are all incomplete/invalid.

Summary of Changes:
add this to beginning of Command::FinalizeCommandsMessage():

mInvokeCommandBuilder.GetCommandListBuilder().EndOfCommandList()

fixes project-chip#5789
  • Loading branch information
yunhanw-google authored Apr 6, 2021
1 parent 020ceab commit e489944
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/app/Command.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ CHIP_ERROR Command::Init(Messaging::ExchangeManager * apExchangeMgr, Interaction
CHIP_ERROR Command::Reset()
{
CHIP_ERROR err = CHIP_NO_ERROR;

CommandList::Builder commandListBuilder;
ClearExistingExchangeContext();

if (mCommandMessageBuf.IsNull())
Expand All @@ -66,7 +66,8 @@ CHIP_ERROR Command::Reset()
err = mInvokeCommandBuilder.Init(&mCommandMessageWriter);
SuccessOrExit(err);

mInvokeCommandBuilder.CreateCommandListBuilder();
commandListBuilder = mInvokeCommandBuilder.CreateCommandListBuilder();
SuccessOrExit(commandListBuilder.GetError());
MoveToState(CommandState::Initialized);

mCommandIndex = 0;
Expand Down Expand Up @@ -265,6 +266,9 @@ CHIP_ERROR Command::FinalizeCommandsMessage()
{
CHIP_ERROR err = CHIP_NO_ERROR;

CommandList::Builder commandListBuilder = mInvokeCommandBuilder.GetCommandListBuilder().EndOfCommandList();
SuccessOrExit(commandListBuilder.GetError());

mInvokeCommandBuilder.EndOfInvokeCommand();
err = mInvokeCommandBuilder.GetError();
SuccessOrExit(err);
Expand Down

0 comments on commit e489944

Please sign in to comment.