Prevent setStartTimeUs from integer overflow
Test: make cts -j123 && cts-tradefed run cts-dev -m \
CtsMediaTestCases --compatibility:module-arg \
CtsMediaTestCases:include-annotation:\
android.platform.test.annotations.RequiresDevice
Bug: 64227921
Change-Id: I06f59ddf3ce12b46c046eb4de852ee4e11545d9f
diff --git a/media/libstagefright/omx/GraphicBufferSource.cpp b/media/libstagefright/omx/GraphicBufferSource.cpp
index 1917d2a..a70005e 100644
--- a/media/libstagefright/omx/GraphicBufferSource.cpp
+++ b/media/libstagefright/omx/GraphicBufferSource.cpp
@@ -1199,7 +1199,8 @@
Mutex::Autolock autoLock(mMutex);
mSkipFramesBeforeNs =
- (skipFramesBeforeUs > 0) ? (skipFramesBeforeUs * 1000) : -1ll;
+ (skipFramesBeforeUs > 0 && skipFramesBeforeUs <= INT64_MAX / 1000) ?
+ (skipFramesBeforeUs * 1000) : -1ll;
return OK;
}