Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix vuln OSV-2024-382 #1698

Open
wants to merge 5 commits into
base: dev
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions Packet++/src/UdpLayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,21 @@ namespace pcpp

uint16_t UdpLayer::getSrcPort() const
{
if (m_DataLen < sizeof(udphdr))
{
PCPP_LOG_ERROR("Buffer too small to access source port");
return 0; // Return an invalid port number
}
return be16toh(getUdpHeader()->portSrc);
}

uint16_t UdpLayer::getDstPort() const
{
if (m_DataLen < sizeof(udphdr))
{
PCPP_LOG_ERROR("Buffer too small to access destination port");
return 0; // Return an invalid port number
}
return be16toh(getUdpHeader()->portDst);
}

Expand Down Expand Up @@ -150,6 +160,11 @@ namespace pcpp

void UdpLayer::computeCalculateFields()
{
if (m_DataLen < sizeof(udphdr))
tigercosmos marked this conversation as resolved.
Show resolved Hide resolved
{
PCPP_LOG_ERROR("Buffer too small to calculate fields");
return;
}
udphdr* udpHdr = (udphdr*)m_Data;
udpHdr->length = htobe16(m_DataLen);
calculateChecksum(true);
Expand Down
Loading