Skip to content

Commit

Permalink
Add an index check to prevent out of index
Browse files Browse the repository at this point in the history
  • Loading branch information
HyeockJinKim authored and Sean-Der committed Aug 2, 2024
1 parent 0967ee9 commit f7f1a05
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion codecs/h264_packet.go
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,11 @@ func (p *H264Packet) parseBody(payload []byte) ([]byte, error) {
currOffset := int(stapaHeaderSize)
result := []byte{}
for currOffset < len(payload) {
naluSize := int(binary.BigEndian.Uint16(payload[currOffset:]))
naluSizeBytes := payload[currOffset:]
if len(naluSizeBytes) < stapaNALULengthSize {
break
}
naluSize := int(binary.BigEndian.Uint16(naluSizeBytes))
currOffset += stapaNALULengthSize

if len(payload) < currOffset+naluSize {
Expand Down

0 comments on commit f7f1a05

Please sign in to comment.