Skip to content

Commit

Permalink
Fix crash in NamedPipeCommands.cpp caused by stack-buffer-underflow (#…
Browse files Browse the repository at this point in the history
…36465)

* Fix stack-buffer-underflow in NamedPipeCommands.cpp

* Update NamedPipeCommands.cpp
  • Loading branch information
BoB13-Matter authored Nov 15, 2024
1 parent 3efd3d6 commit d73c821
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions examples/platform/linux/NamedPipeCommands.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,15 @@ void * NamedPipeCommands::EventCommandListenerTask(void * arg)
break;
}

ssize_t readBytes = read(fd, readbuf, kChipEventCmdBufSize);
readbuf[readBytes - 1] = '\0';
ChipLogProgress(NotSpecified, "Received payload: \"%s\"", readbuf);
ssize_t readBytes = read(fd, readbuf, kChipEventCmdBufSize);
if (readBytes > 0)
{
readbuf[readBytes - 1] = '\0';
ChipLogProgress(NotSpecified, "Received payload: \"%s\"", readbuf);

// Process the received command request from event fifo
self->mDelegate->OnEventCommandReceived(readbuf);
// Process the received command request from event fifo
self->mDelegate->OnEventCommandReceived(readbuf);
}

close(fd);
}
Expand Down

0 comments on commit d73c821

Please sign in to comment.