Skip to content

Commit

Permalink
fix(LL-DASH): Fix index out of bound issue when parsing mp4 segment (s…
Browse files Browse the repository at this point in the history
  • Loading branch information
percytse authored May 17, 2021
1 parent f09616f commit e02d28c
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions lib/util/mp4_parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,12 @@ shaka.util.Mp4Parser = class {
parseNext(absStart, reader, partialOkay, stopOnPartial) {
const start = reader.getPosition();

// size(4 bytes) + type(4 bytes) = 8 bytes
if (stopOnPartial && start + 8 > reader.getLength()) {
this.done_ = true;
return;
}

let size = reader.readUint32();
const type = reader.readUint32();
const name = shaka.util.Mp4Parser.typeToString(type);
Expand All @@ -122,6 +128,10 @@ shaka.util.Mp4Parser = class {
size = reader.getLength() - start;
break;
case 1:
if (stopOnPartial && reader.getPosition() + 8 > reader.getLength()) {
this.done_ = true;
return;
}
size = reader.readUint64();
has64BitSize = true;
break;
Expand All @@ -134,6 +144,10 @@ shaka.util.Mp4Parser = class {
let flags = null;

if (this.headers_[type] == shaka.util.Mp4Parser.BoxType_.FULL_BOX) {
if (stopOnPartial && reader.getPosition() + 4 > reader.getLength()) {
this.done_ = true;
return;
}
const versionAndFlags = reader.readUint32();
version = versionAndFlags >>> 24;
flags = versionAndFlags & 0xFFFFFF;
Expand Down

0 comments on commit e02d28c

Please sign in to comment.