Skip to content

Commit bc5c08d

Browse files
authored
Fix vuln OSV-2024-343 (seladb#1680)
1 parent 680cfd7 commit bc5c08d

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

Packet++/src/BgpLayer.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -542,6 +542,11 @@ namespace pcpp
542542
if (headerLen >= minLen)
543543
{
544544
size_t withdrawnRouteLen = getWithdrawnRoutesLength();
545+
// Ensure the memory access is within bounds
546+
if (sizeof(bgp_common_header) + sizeof(uint16_t) + withdrawnRouteLen + sizeof(uint16_t) > headerLen)
547+
{
548+
return 0; // Invalid access, return 0
549+
}
545550
uint16_t res =
546551
be16toh(*(uint16_t*)(m_Data + sizeof(bgp_common_header) + sizeof(uint16_t) + withdrawnRouteLen));
547552
if ((size_t)res > headerLen - minLen - withdrawnRouteLen)

0 commit comments

Comments
 (0)