Skip to content

Commit

Permalink
Validate value lenght - 0 size value should not copy anything
Browse files Browse the repository at this point in the history
  • Loading branch information
andy31415 committed Nov 17, 2021
1 parent 79fbcbf commit 50a9c88
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/platform/Darwin/DnssdImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -434,8 +434,9 @@ static CHIP_ERROR GetAddrInfo(void * context, DnssdResolveCallback callback, uin
// Truncation, but nothing better we can do
valueLen = sizeof(value) - 1;
}

memcpy(value, valuePtr, valueLen - 1);
if (valueLen > 1) {
memcpy(value, valuePtr, valueLen - 1);
}
value[valueLen] = 0;

sdCtx->textEntries.push_back(TextEntry{ strdup(key), reinterpret_cast<const uint8_t *>(strdup(value)), valueLen });
Expand Down

0 comments on commit 50a9c88

Please sign in to comment.