Skip to content

Commit

Permalink
improve mp3 parser
Browse files Browse the repository at this point in the history
  • Loading branch information
tballison committed Apr 8, 2020
1 parent a3fef30 commit 57193f5
Showing 1 changed file with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
* be turned into useful data.
*/
public class ID3v2Frame implements MP3Frame {

private static final int MAX_RECORD_SIZE = 1_000_000;
private int majorVersion;
private int minorVersion;
private int flags;
Expand Down Expand Up @@ -180,6 +182,10 @@ protected static byte[] readFully(InputStream inp, int length)
}
protected static byte[] readFully(InputStream inp, int length, boolean shortDataIsFatal)
throws IOException {
if (length > MAX_RECORD_SIZE) {
throw new IOException("Record size ("+length+
" bytes) is larger than the allowed record size: "+MAX_RECORD_SIZE);
}
byte[] b = new byte[length];

int pos = 0;
Expand Down

0 comments on commit 57193f5

Please sign in to comment.