Avoid reading at negative offsets
Avoid making MPEG4Extractor read from negative data source offsets,
but also make FileSource::readAt() handle them gracefully.
Bug: 141242340
Test: poc, manual
Change-Id: If82dcaec43a63b71d24a5572eeea5e0685fb4a1c
diff --git a/media/libdatasource/FileSource.cpp b/media/libdatasource/FileSource.cpp
index bbf7dda..3d34d0c 100644
--- a/media/libdatasource/FileSource.cpp
+++ b/media/libdatasource/FileSource.cpp
@@ -107,6 +107,9 @@
Mutex::Autolock autoLock(mLock);
if (mLength >= 0) {
+ if (offset < 0) {
+ return UNKNOWN_ERROR;
+ }
if (offset >= mLength) {
return 0; // read beyond EOF.
}