Comcast / Comcast/gots

Panic when calling pes.NewPESHeader

Open
#52 2 comments 1 reaction 0 assignees View on GitHub
Dominant language
Go
Stars
310
Forks
88
PR merge metrics
No merged PRs in 30d

Description

While building a tool to do an analysis of MPEGTS for HLS delivery, ran into a panic while calling pes.NewPESHeader.

```
pes := new(pESHeader)
var err error

if CheckLength(pesBytes, "PES", 6) {

pes.packetStartCodePrefix = uint32(pesBytes[0])<<16 | uint32(pesBytes[1])<<8 | uint32(pesBytes[2])

pes.streamId = uint8(pesBytes[3])
pes.pesPacketLength = uint16(pesBytes[4])<<8 | uint16(pesBytes[5])
---> pes.dataAlignment = pesBytes[6]&0x04 != 0
dataStartIndex := 6
```

The code panics on the pesBytes[6] check being out of bounds.

I think that CheckLength should be called with a value of seven in this case since it's checking the length of the byte array which is one-based, but the index is zero based.

Thank you for this code, it made getting started much easier!

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.