summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhil Burk <philburk@google.com>2018-09-05 22:03:11 -0700
committerandroid-build-merger <android-build-merger@google.com>2018-09-05 22:03:11 -0700
commit59782c5ddd603fa00ff0446281e868d7d604eec7 (patch)
tree49c24f166de60c37d93bc0ebc29414880bfe3f81
parent67a8b0af7d6dfafe4823446ebee917b5eb0daffc (diff)
parente9fa941fa5935ed2e516ba776defe43ca2a1262e (diff)
downloadsonivox-pie-b4s4-dev.tar.gz
[automerger] sonivox: prevent rejection of good but large MIDI files am: 123051dd02 am: cd77ee58e5 am: b1d2719524 am: aaf28257f1 am: 2ba5fc650c am: ccea49f5ae am: 1af91e35b6android-9.0.0_r47android-9.0.0_r46android-9.0.0_r45android-9.0.0_r44android-9.0.0_r43android-9.0.0_r42android-9.0.0_r41android-9.0.0_r40android-9.0.0_r37android-9.0.0_r36pie-qpr3-s1-releasepie-qpr3-releasepie-qpr3-b-releasepie-b4s4-dev
am: e9fa941fa5 Change-Id: Icb89d3699a4fd449f729ece958717b778e6619ba
-rw-r--r--arm-wt-22k/lib_src/eas_public.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/arm-wt-22k/lib_src/eas_public.c b/arm-wt-22k/lib_src/eas_public.c
index eb41113..19481b5 100644
--- a/arm-wt-22k/lib_src/eas_public.c
+++ b/arm-wt-22k/lib_src/eas_public.c
@@ -1247,12 +1247,13 @@ static EAS_RESULT EAS_ParseEvents (S_EAS_DATA *pEASData, EAS_HANDLE pStream, EAS
EAS_BOOL done;
EAS_INT yieldCount = YIELD_EVENT_COUNT;
EAS_U32 time = 0;
+
// This constant is the maximum number of events that can be processed in a single time slice.
// A typical ringtone will contain a few events per time slice.
// Extremely dense ringtones might go up to 50 events.
// If we see this many events then the file is probably stuck in an infinite loop
- // and should be aborted. In our testing, it took less than 100 msec to hit this limit.
- static const EAS_INT MAX_EVENT_COUNT = 50000;
+ // and should be aborted.
+ static const EAS_INT MAX_EVENT_COUNT = 100000;
EAS_INT eventCount = 0;
/* does this parser have a time function? */
@@ -1308,10 +1309,14 @@ static EAS_RESULT EAS_ParseEvents (S_EAS_DATA *pEASData, EAS_HANDLE pStream, EAS
return result;
}
}
- // An infinite loop within a single frame of a ringtone file can cause this function
+
+ // An infinite loop within a ringtone file can cause this function
// to loop forever. Try to detect that and return an error.
- if (++eventCount >= MAX_EVENT_COUNT) {
- ALOGE("%s() aborting, %d events without advancing to next frame",
+ // Only check when playing. Otherwise a very large file could be rejected
+ // when scanning the entire file in a single call to this function.
+ // OTA files will only do infinite loops when in eParserModePlay.
+ if (++eventCount >= MAX_EVENT_COUNT && parseMode == eParserModePlay) {
+ ALOGE("%s() aborting, %d events. Infinite loop in song file?!",
__func__, eventCount);
android_errorWriteLog(0x534e4554, "68664359");
return EAS_ERROR_FILE_POS;