Skip to content

Commit

Permalink
Fix thread names for k32w's DiagnosticDataProvider. (#26892)
Browse files Browse the repository at this point in the history
The old code was copying in N-1 chars, then creating a string of length N from
them, so ending up with a random byte in the string, which could lead to the
string not being valid UTF-8.

Fixes #26891
  • Loading branch information
bzbarsky-apple authored and pull[bot] committed Nov 6, 2023
1 parent 9f24541 commit 1210704
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions src/platform/nxp/k32w/k32w0/DiagnosticDataProviderImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,7 @@ CHIP_ERROR DiagnosticDataProviderImpl::GetThreadMetrics(ThreadMetrics ** threadM
{
ThreadMetrics * thread = (ThreadMetrics *) pvPortMalloc(sizeof(ThreadMetrics));

strncpy(thread->NameBuf, taskStatusArray[x].pcTaskName, kMaxThreadNameLength - 1);
thread->NameBuf[kMaxThreadNameLength] = '\0';
Platform::CopyString(thread->NameBuf, taskStatusArray[x].pcTaskName);
thread->name.Emplace(CharSpan::fromCharString(thread->NameBuf));
thread->id = taskStatusArray[x].xTaskNumber;

Expand Down

0 comments on commit 1210704

Please sign in to comment.