Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 3366d796 authored by Andy Hung's avatar Andy Hung Committed by android-build-merger
Browse files

Add EFFECT_CMD_SET_PARAM parameter checking am: e4a1d915 am: 19d8a613 am:...

Add EFFECT_CMD_SET_PARAM parameter checking am: e4a1d915 am: 19d8a613 am: ebd9f102 am: d37cf468 am: ced0dd63 am: 00acbf03 am: 1ab50af9 am: 18e5ce68 am: 0330f4ce am: 41880fe2 am: 7b2ce563 am: 4faee5a8
am: a3e0e402

Change-Id: I56558cd3dff5fcafafd6fe5cd542b57bf836f544
parents c02035e9 a3e0e402
Loading
Loading
Loading
Loading
+23 −0
Original line number Diff line number Diff line
@@ -555,6 +555,13 @@ status_t AudioFlinger::EffectModule::remove_effect_from_hal_l()
    return NO_ERROR;
}

// round up delta valid if value and divisor are positive.
template <typename T>
static T roundUpDelta(const T &value, const T &divisor) {
    T remainder = value % divisor;
    return remainder == 0 ? 0 : divisor - remainder;
}

status_t AudioFlinger::EffectModule::command(uint32_t cmdCode,
                                             uint32_t cmdSize,
                                             void *pCmdData,
@@ -576,6 +583,22 @@ status_t AudioFlinger::EffectModule::command(uint32_t cmdCode,
        android_errorWriteLog(0x534e4554, "29251553");
        return -EINVAL;
    }
    if ((cmdCode == EFFECT_CMD_SET_PARAM
            || cmdCode == EFFECT_CMD_SET_PARAM_DEFERRED) &&  // DEFERRED not generally used
        (sizeof(effect_param_t) > cmdSize
            || ((effect_param_t *)pCmdData)->psize > cmdSize
                                                     - sizeof(effect_param_t)
            || ((effect_param_t *)pCmdData)->vsize > cmdSize
                                                     - sizeof(effect_param_t)
                                                     - ((effect_param_t *)pCmdData)->psize
            || roundUpDelta(((effect_param_t *)pCmdData)->psize, (uint32_t)sizeof(int)) >
                                                     cmdSize
                                                     - sizeof(effect_param_t)
                                                     - ((effect_param_t *)pCmdData)->psize
                                                     - ((effect_param_t *)pCmdData)->vsize)) {
        android_errorWriteLog(0x534e4554, "30204301");
        return -EINVAL;
    }
    status_t status = (*mEffectInterface)->command(mEffectInterface,
                                                   cmdCode,
                                                   cmdSize,