summaryrefslogtreecommitdiff
path: root/arm-wt-22k
diff options
context:
space:
mode:
authorMarco Nelissen <marcone@google.com>2019-07-12 10:41:21 -0700
committerMarco Nelissen <marcone@google.com>2019-07-12 10:41:21 -0700
commit3d94279769f4117670127844e8b5a6864130a70e (patch)
tree5f8fc2a7d0daaae0428382f2edcd9490a92111cf /arm-wt-22k
parent16637589986a5aef7fdabbb632d6f1de793eb9c6 (diff)
downloadsonivox-3d94279769f4117670127844e8b5a6864130a70e.tar.gz
Fix potential integer overflow
Bug: 136019012 Test: CTS Change-Id: I6c5950e768f65e3dd97b75b8494c450524120332
Diffstat (limited to 'arm-wt-22k')
-rw-r--r--arm-wt-22k/lib_src/eas_smf.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/arm-wt-22k/lib_src/eas_smf.c b/arm-wt-22k/lib_src/eas_smf.c
index 48fc456..b690de1 100644
--- a/arm-wt-22k/lib_src/eas_smf.c
+++ b/arm-wt-22k/lib_src/eas_smf.c
@@ -874,8 +874,20 @@ static EAS_RESULT SMF_ParseMetaEvent (S_EAS_DATA *pEASData, S_SMF_DATA *pSMFData
return result;
temp = (temp << 8) | c;
}
-
- pSMFData->tickConv = (EAS_U16) (((temp * 1024) / pSMFData->ppqn + 500) / 1000);
+ {
+ // pSMFData->tickConv = (EAS_U16) (((temp * 1024) / pSMFData->ppqn + 500) / 1000);
+ uint64_t temp64;
+ if (__builtin_mul_overflow(temp, 1024, &temp64) ||
+ pSMFData->ppqn == 0 ||
+ (temp64 /= pSMFData->ppqn, false) ||
+ __builtin_add_overflow(temp64, 500, &temp64) ||
+ (temp64 /= 1000, false) ||
+ temp64 > 65535) {
+ pSMFData->tickConv = 65535;
+ } else {
+ pSMFData->tickConv = (EAS_U16) temp64;
+ }
+ }
pSMFData->flags |= SMF_FLAGS_HAS_TEMPO;
}