diff options
author | akirilov <akirilov@google.com> | 2018-04-03 15:28:55 -0700 |
---|---|---|
committer | android-build-merger <android-build-merger@google.com> | 2018-04-03 15:28:55 -0700 |
commit | 096edd76c81c7e9ab06527b43aa8051d16289c19 (patch) | |
tree | 330602c62544ba2a780117efe94fed0f92960407 | |
parent | f56b92df2f9ee4254c53445b371088d27e3ef14b (diff) | |
parent | c315f9d3f645d9338ae2704d109d1bfa43d0049c (diff) | |
download | sonivox-096edd76c81c7e9ab06527b43aa8051d16289c19.tar.gz |
[automerger] sonivox: fix hang caused by bad meta-event am: ba9ea23466 am: 3983856ec1 am: 59644944e2 am: f3c51f7f1e am: d2901553df am: b0081b7c58 am: 88510ce7be am: ef8ae5940d am: 52fae8ba07
am: c315f9d3f6
Change-Id: I8947d8ee2917355ab51e4010265f7ff38b42a5d9
-rw-r--r-- | arm-wt-22k/lib_src/eas_smf.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/arm-wt-22k/lib_src/eas_smf.c b/arm-wt-22k/lib_src/eas_smf.c index 8b54b8e..3c284eb 100644 --- a/arm-wt-22k/lib_src/eas_smf.c +++ b/arm-wt-22k/lib_src/eas_smf.c @@ -29,6 +29,8 @@ *---------------------------------------------------------------------------- */ +#include "log/log.h" + #include "eas_data.h" #include "eas_miditypes.h" #include "eas_parser.h" @@ -833,6 +835,20 @@ static EAS_RESULT SMF_ParseMetaEvent (S_EAS_DATA *pEASData, S_SMF_DATA *pSMFData /* get the current file position so we can skip the event */ if ((result = EAS_HWFilePos(pEASData->hwInstData, pSMFStream->fileHandle, &pos)) != EAS_SUCCESS) return result; + + /* prevent a large unsigned length from being treated as a negative length */ + if ((EAS_I32) len < 0) { + /* note that EAS_I32 is a long, which can be 64-bits on some computers */ + ALOGE("b/68953854 SMF_ParseMetaEvent, negative len = %ld\n", (EAS_I32) len); + return EAS_ERROR_FILE_FORMAT; + } + /* prevent numeric overflow caused by a very large len, assume pos > 0 */ + const EAS_I32 EAS_I32_MAX = 0x7FFFFFFF; + if ((EAS_I32) len > (EAS_I32_MAX - pos)) { + ALOGE("b/68953854 SMF_ParseMetaEvent, too large len = %ld\n", (EAS_I32) len); + return EAS_ERROR_FILE_FORMAT; + } + pos += (EAS_I32) len; /* end of track? */ |