Skip to content

Commit

Permalink
Fix possible buffer leak in ChipLinuxStorageIni::GetBinaryBlobValue (#…
Browse files Browse the repository at this point in the history
…2856)

It's possible for us to allocate encodedData but then never reach the
Base64Decode call because of failing buffer length checks (e.g. if the
encodedData buffer is more than 65KB).  So we should make sure we free
encodedData as long as it's not null.
  • Loading branch information
bzbarsky-apple authored and Damian-Nordic committed Sep 29, 2020
1 parent 128961a commit 1199551
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/platform/Linux/CHIPLinuxStorageIni.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -302,11 +302,11 @@ CHIP_ERROR ChipLinuxStorageIni::GetBinaryBlobValue(const char * key, uint8_t * d
{
retval = CHIP_ERROR_DECODE_FAILED;
}
}

if (encodedData)
{
chip::Platform::MemoryFree(encodedData);
}
if (encodedData)
{
chip::Platform::MemoryFree(encodedData);
}

return retval;
Expand Down

0 comments on commit 1199551

Please sign in to comment.