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 committed May 2, 2024
1 parent bc5124c commit 2528060
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

Check warning on line 236 in codecs/h264_packet.go

View check run for this annotation

Codecov / codecov/patch

codecs/h264_packet.go#L236

Added line #L236 was not covered by tests
}
naluSize := int(binary.BigEndian.Uint16(naluSizeBytes))
currOffset += stapaNALULengthSize

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

0 comments on commit 2528060

Please sign in to comment.