mirror of
https://github.com/samsonjs/media.git
synced 2026-04-26 14:57:47 +00:00
Robustness fixes for WebM extractor.
- readFully calls when reading a string or varint may have 0 length. The behavior of a 0 length read isn't well defined either at the ExtractorInput or DataSource level, particularly when the read may also coincide with EOS. We'll work on defining these cases properly going forward, but in the meantime this fix avoids attempting 0 length reads. - [Aside] UTF8 the is guaranteed default charset on Android. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=117130356
This commit is contained in:
parent
9f4e46bd3c
commit
9d732d8c27
2 changed files with 8 additions and 4 deletions
|
|
@ -22,7 +22,6 @@ import com.google.android.exoplayer.util.Assertions;
|
|||
|
||||
import java.io.EOFException;
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.Stack;
|
||||
|
||||
/**
|
||||
|
|
@ -215,9 +214,12 @@ import java.util.Stack;
|
|||
*/
|
||||
private String readString(ExtractorInput input, int byteLength)
|
||||
throws IOException, InterruptedException {
|
||||
if (byteLength == 0) {
|
||||
return "";
|
||||
}
|
||||
byte[] stringBytes = new byte[byteLength];
|
||||
input.readFully(stringBytes, 0, byteLength);
|
||||
return new String(stringBytes, Charset.forName(C.UTF8_NAME));
|
||||
return new String(stringBytes);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -84,8 +84,10 @@ import java.io.IOException;
|
|||
return C.RESULT_MAX_LENGTH_EXCEEDED;
|
||||
}
|
||||
|
||||
// Read the remaining bytes.
|
||||
input.readFully(scratch, 1, length - 1);
|
||||
if (length != 1) {
|
||||
// Read the remaining bytes.
|
||||
input.readFully(scratch, 1, length - 1);
|
||||
}
|
||||
|
||||
state = STATE_BEGIN_READING;
|
||||
return assembleVarint(scratch, length, removeLengthMask);
|
||||
|
|
|
|||
Loading…
Reference in a new issue