- format + fix invalid memory access

This commit is contained in:
Dmytro Bogovych 2022-06-18 22:24:41 +03:00
parent 9d79c01be0
commit e342abe2f5
2 changed files with 298 additions and 294 deletions

View File

@ -152,6 +152,8 @@ int RTPPacket::ParseRawPacket(RTPRawPacket &rawpack)
csrccount = rtpheader->csrccount; csrccount = rtpheader->csrccount;
payloadoffset = sizeof(RTPHeader)+(int)(csrccount*sizeof(uint32_t)); payloadoffset = sizeof(RTPHeader)+(int)(csrccount*sizeof(uint32_t));
if ((size_t)payloadoffset > packetlen)
return ERR_RTP_PACKET_INVALIDPACKET;
if (rtpheader->padding) // adjust payload length to take padding into account if (rtpheader->padding) // adjust payload length to take padding into account
{ {
@ -167,6 +169,8 @@ int RTPPacket::ParseRawPacket(RTPRawPacket &rawpack)
{ {
rtpextheader = (RTPExtensionHeader *)(packetbytes+payloadoffset); rtpextheader = (RTPExtensionHeader *)(packetbytes+payloadoffset);
payloadoffset += sizeof(RTPExtensionHeader); payloadoffset += sizeof(RTPExtensionHeader);
if ((size_t)payloadoffset > packetlen)
return ERR_RTP_PACKET_INVALIDPACKET;
exthdrlen = ntohs(rtpextheader->length); exthdrlen = ntohs(rtpextheader->length);
payloadoffset += ((int)exthdrlen)*sizeof(uint32_t); payloadoffset += ((int)exthdrlen)*sizeof(uint32_t);
} }