Skip to content

Commit

Permalink
Bugfix: packet buffer counter going negative and triggering UBSan Iss…
Browse files Browse the repository at this point in the history
…ue (#35708)

* Fix for issue where the packet buffer counter (sResourcesInUse[kSystemLayer_NumPacketBufs]) in SystemStats is going negative and underflowing, triggering a UBSan issue during fuzzing

* Integrating comments
  • Loading branch information
Alami-Amine authored and pull[bot] committed Oct 22, 2024
1 parent ac5b775 commit 083a5a7
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/system/SystemPacketBuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,8 @@ void PacketBufferHandle::InternalRightSize()
return;
}

SYSTEM_STATS_INCREMENT(chip::System::Stats::kSystemLayer_NumPacketBufs);

uint8_t * const newStart = newBuffer->ReserveStart();
newBuffer->next = nullptr;
newBuffer->payload = newStart + (payload - start);
Expand Down

0 comments on commit 083a5a7

Please sign in to comment.