mirror of
https://github.com/samsonjs/media.git
synced 2026-04-27 15:07:40 +00:00
Fix possible failure in CachedContentIndex encrypted cache index file read.
Encryption key in index file is read by DataInputStream.read() which may return less bytes than required. Replaced it with readFully() which should read full length of data. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=140597693
This commit is contained in:
parent
501f54a8a6
commit
257671467f
1 changed files with 5 additions and 1 deletions
|
|
@ -15,6 +15,7 @@
|
||||||
*/
|
*/
|
||||||
package com.google.android.exoplayer2.upstream.cache;
|
package com.google.android.exoplayer2.upstream.cache;
|
||||||
|
|
||||||
|
import android.util.Log;
|
||||||
import android.util.SparseArray;
|
import android.util.SparseArray;
|
||||||
import com.google.android.exoplayer2.C;
|
import com.google.android.exoplayer2.C;
|
||||||
import com.google.android.exoplayer2.upstream.cache.Cache.CacheException;
|
import com.google.android.exoplayer2.upstream.cache.Cache.CacheException;
|
||||||
|
|
@ -55,6 +56,8 @@ import javax.crypto.spec.SecretKeySpec;
|
||||||
|
|
||||||
private static final int FLAG_ENCRYPTED_INDEX = 1;
|
private static final int FLAG_ENCRYPTED_INDEX = 1;
|
||||||
|
|
||||||
|
private static final String TAG = "CachedContentIndex";
|
||||||
|
|
||||||
private final HashMap<String, CachedContent> keyToContent;
|
private final HashMap<String, CachedContent> keyToContent;
|
||||||
private final SparseArray<String> idToKey;
|
private final SparseArray<String> idToKey;
|
||||||
private final AtomicFile atomicFile;
|
private final AtomicFile atomicFile;
|
||||||
|
|
@ -224,7 +227,7 @@ import javax.crypto.spec.SecretKeySpec;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
byte[] initializationVector = new byte[16];
|
byte[] initializationVector = new byte[16];
|
||||||
input.read(initializationVector);
|
input.readFully(initializationVector);
|
||||||
IvParameterSpec ivParameterSpec = new IvParameterSpec(initializationVector);
|
IvParameterSpec ivParameterSpec = new IvParameterSpec(initializationVector);
|
||||||
try {
|
try {
|
||||||
cipher.init(Cipher.DECRYPT_MODE, secretKeySpec, ivParameterSpec);
|
cipher.init(Cipher.DECRYPT_MODE, secretKeySpec, ivParameterSpec);
|
||||||
|
|
@ -245,6 +248,7 @@ import javax.crypto.spec.SecretKeySpec;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
|
Log.e(TAG, "Error reading cache content index file.", e);
|
||||||
return false;
|
return false;
|
||||||
} finally {
|
} finally {
|
||||||
if (input != null) {
|
if (input != null) {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue