Skip to content

Commit

Permalink
Check at the start of the function
Browse files Browse the repository at this point in the history
  • Loading branch information
oss-patch authored Jan 31, 2025
1 parent ac92d06 commit 0ebbb23
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion Packet++/src/UdpLayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,12 +160,12 @@ namespace pcpp

void UdpLayer::computeCalculateFields()
{
udphdr* udpHdr = (udphdr*)m_Data;
if (m_DataLen < sizeof(udphdr))
{
PCPP_LOG_ERROR("Buffer too small to calculate fields");
return;
}
udphdr* udpHdr = (udphdr*)m_Data;
udpHdr->length = htobe16(m_DataLen);
calculateChecksum(true);
}
Expand Down

0 comments on commit 0ebbb23

Please sign in to comment.