Skip to content

Commit a7d2800

Browse files
committed
fixed an issue with the PES parser removing too many bytes when parsing stuffing bytes
1 parent 1b4bdae commit a7d2800

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/tsdemux.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -821,6 +821,7 @@ TSDCode tsd_parse_pes(TSDemuxContext *ctx,
821821
ptr++;
822822
pes->header_data_length = *ptr;
823823
ptr++;
824+
const uint8_t *header_end = &ptr[pes->header_data_length];
824825
if(pes->flags & TSD_PPF_PTS_FLAG) {
825826
uint64_t pts1 = (uint64_t) (((*ptr) >> 1) & 0x07);
826827
uint64_t pts2 = (uint64_t) ((parse_u16(ptr+1) >> 1) & 0x7FFF);
@@ -952,7 +953,7 @@ TSDCode tsd_parse_pes(TSDemuxContext *ctx,
952953
}
953954
}
954955
// get past any stuffing
955-
while(*ptr == 0xFF) {
956+
while(ptr < header_end && *ptr == 0xFF) {
956957
ptr++;
957958
}
958959
pes->data_bytes = ptr;

0 commit comments

Comments
 (0)