Skip to content

Commit

Permalink
Fixed possible infinite read loop in mpeg parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
Walkyst committed Dec 15, 2022
1 parent ea43154 commit b94abef
Showing 1 changed file with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,13 @@ public MpegSectionInfo nextChild(MpegSectionInfo parent) throws IOException {
}

long length = Integer.toUnsignedLong(lengthField);
return new MpegSectionInfo(offset, length, readFourCC());
String type = readFourCC();

if (length == 1) {
length = data.readLong();
}

return new MpegSectionInfo(offset, length, type);
}

/**
Expand All @@ -79,7 +85,7 @@ public void skip(MpegSectionInfo section) {
*/
public String readFourCC() throws IOException {
data.readFully(fourCcBuffer);
return new String(fourCcBuffer, "ISO-8859-1");
return new String(fourCcBuffer, StandardCharsets.ISO_8859_1);
}

/**
Expand Down

0 comments on commit b94abef

Please sign in to comment.