Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixing UBSan issues that showed up in all-clusters app (#35580)
* Fix for unsigned integer overflow: Error Message: BufferWriter.cpp:76:16: runtime error: unsigned integer overflow: 0 - 1 cannot be represented in type 'size_t' (aka 'unsigned long') when size becomes 0 and we are in while (size-- > 0), then size will become less than 0, which should be avoided since it is an unsigned (although technically it wraps around, UBSAN complains about it). Fix: stop size from decrement past 0, by moving size-- inside the loop * Fix null pointer passed to non-null argument in CHIPMemString.h Error Message: CHIPMemString.h:88:22: runtime error: null pointer passed as argument 2, which is declared to never be null when PI= is in mDNS TXT record (its value is empty) , and Dnssd::Internal::GetPairingInstruction calls CopyString, source is an empty bytespan and source.data() will return a null pointer, that will be passed to memcpy Fix: avoid memcpy in that case.
- Loading branch information