summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJean-Michel Trivi <jmtrivi@google.com>2018-09-10 15:50:19 -0700
committerRohit Yengisetty <rngy@google.com>2018-10-16 16:05:29 -0700
commita83d33861043df19895bf08179fa45c379c737ae (patch)
treea0ec6302e8d8ef03df6e451665233526e65a04c3
parent8d2bc936cc3e707ad083c1355cc1fa754edd9cca (diff)
downloadaac-nougat-mr1-security-release.tar.gz
Check validity of pSettings->noOfPatches to prevent out of bounds access in lppTransposer(), which can also cause memSize to be negative. Bug: 112160868 Test: see poc in bug Change-Id: I77bd1e1dfab3bac92b4522170bdc3c9eb56fdf82 (cherry picked from commit 2eaadebcb6036b3e1850590378c0f56ca47e4735)
-rw-r--r--libSBRdec/src/lpp_tran.cpp37
1 files changed, 24 insertions, 13 deletions
diff --git a/libSBRdec/src/lpp_tran.cpp b/libSBRdec/src/lpp_tran.cpp
index 343aec3..c2ca732 100644
--- a/libSBRdec/src/lpp_tran.cpp
+++ b/libSBRdec/src/lpp_tran.cpp
@@ -96,6 +96,10 @@ amm-info@iis.fraunhofer.de
\sa lppTransposer(), main_audio.cpp, sbr_scale.h, \ref documentationOverview
*/
+#ifdef __ANDROID__
+#include <cutils/log.h>
+#endif
+
#include "lpp_tran.h"
#include "sbr_ram.h"
@@ -256,7 +260,6 @@ void lppTransposer (HANDLE_SBR_LPP_TRANS hLppTrans, /*!< Handle of lpp transp
int ovLowBandShift;
int lowBandShift;
/* int ovHighBandShift;*/
- int targetStopBand;
alphai[0] = FL2FXCONST_SGL(0.0f);
@@ -273,24 +276,32 @@ void lppTransposer (HANDLE_SBR_LPP_TRANS hLppTrans, /*!< Handle of lpp transp
autoCorrLength = pSettings->nCols + pSettings->overlap;
- /* Set upper subbands to zero:
- This is required in case that the patches do not cover the complete highband
- (because the last patch would be too short).
- Possible optimization: Clearing bands up to usb would be sufficient here. */
- targetStopBand = patchParam[pSettings->noOfPatches-1].targetStartBand
- + patchParam[pSettings->noOfPatches-1].numBandsInPatch;
+ if (pSettings->noOfPatches > 0) {
+ /* Set upper subbands to zero:
+ This is required in case that the patches do not cover the complete highband
+ (because the last patch would be too short).
+ Possible optimization: Clearing bands up to usb would be sufficient here. */
+ int targetStopBand = patchParam[pSettings->noOfPatches-1].targetStartBand
+ + patchParam[pSettings->noOfPatches-1].numBandsInPatch;
- int memSize = ((64) - targetStopBand) * sizeof(FIXP_DBL);
+ int memSize = ((64) - targetStopBand) * sizeof(FIXP_DBL);
- if (!useLP) {
+ if (!useLP) {
+ for (i = startSample; i < stopSampleClear; i++) {
+ FDKmemclear(&qmfBufferReal[i][targetStopBand], memSize);
+ FDKmemclear(&qmfBufferImag[i][targetStopBand], memSize);
+ }
+ } else
for (i = startSample; i < stopSampleClear; i++) {
FDKmemclear(&qmfBufferReal[i][targetStopBand], memSize);
- FDKmemclear(&qmfBufferImag[i][targetStopBand], memSize);
}
- } else
- for (i = startSample; i < stopSampleClear; i++) {
- FDKmemclear(&qmfBufferReal[i][targetStopBand], memSize);
}
+#ifdef __ANDROID__
+ else {
+ // Safetynet logging
+ android_errorWriteLog(0x534e4554, "112160868");
+ }
+#endif
/* init bwIndex for each patch */
FDKmemclear(bwIndex, MAX_NUM_PATCHES*sizeof(INT));