OSDN Git Service

Bug 3388299 Fix stack buffer overrun
authorGlenn Kasten <gkasten@google.com>
Tue, 25 Jan 2011 17:26:11 +0000 (09:26 -0800)
committerGlenn Kasten <gkasten@google.com>
Tue, 25 Jan 2011 19:04:23 +0000 (11:04 -0800)
Change-Id: I22bf369b42faf04ef5bdc7ca8ebca3d31add2ad6

wilhelm/src/android/android_Effect.cpp

index 5cab91e..38ec90e 100644 (file)
@@ -32,6 +32,8 @@ static const int ENVREVERB_PARAM_SIZE_MAX_SINGLE = sizeof(effect_param_t) + 2 *
 static const int ENVREVERB_PARAM_SIZE_MAX_ALL = sizeof(effect_param_t) + sizeof(int32_t)
         + sizeof(s_reverb_settings);
 
+static const int PRESETREVERB_PARAM_SIZE_MAX = sizeof(effect_param_t) + 2 * sizeof(int32_t);
+
 static inline SLuint32 KEY_FROM_GUID(SLInterfaceID pUuid) {
     return pUuid->time_low;
 }
@@ -366,8 +368,8 @@ void android_prev_init(IPresetReverb* ipr) {
 
 //-----------------------------------------------------------------------------
 android::status_t android_prev_setPreset(android::sp<android::AudioEffect> pFx, uint16_t preset) {
-    android::status_t status = android_fx_setParam(pFx, REVERB_PARAM_PRESET, sizeof(uint16_t),
-            &preset, sizeof(uint16_t));
+    android::status_t status = android_fx_setParam(pFx, REVERB_PARAM_PRESET,
+            PRESETREVERB_PARAM_SIZE_MAX, &preset, sizeof(uint16_t));
     // enable the effect if the preset is different from SL_REVERBPRESET_NONE
     pFx->setEnabled(SL_REVERBPRESET_NONE != preset);
     return status;
@@ -375,7 +377,7 @@ android::status_t android_prev_setPreset(android::sp<android::AudioEffect> pFx,
 
 //-----------------------------------------------------------------------------
 android::status_t android_prev_getPreset(android::sp<android::AudioEffect> pFx, uint16_t* preset) {
-    return android_fx_getParam(pFx, REVERB_PARAM_PRESET, sizeof(uint16_t), preset,
+    return android_fx_getParam(pFx, REVERB_PARAM_PRESET, PRESETREVERB_PARAM_SIZE_MAX, preset,
             sizeof(uint16_t));
 }