Check buffer size in useBuffer in software components

Test: No more crash from oob read/write with running poc.
Bug: 63522430
Change-Id: I232d256eacdfaa9347902fe9b42650999f0d2d85
(cherry picked from commit 4e79910fdb303fd28a37a9401bed1b7fbccb1373)

bool SimpleSoftOMXComponent::isSetParameterAllowed(
        OMX_INDEXTYPE index, const OMX_PTR params) const {
 if (mState == OMX_StateLoaded) {
 return true;
 }

    OMX_U32 portIndex;

 switch (index) {
 case OMX_IndexParamPortDefinition:
 {
 const OMX_PARAM_PORTDEFINITIONTYPE *portDefs =
 (const OMX_PARAM_PORTDEFINITIONTYPE *) params;
 if (!isValidOMXParam(portDefs)) {
 return false;
 }
            portIndex = portDefs->nPortIndex;
 break;
 }

 case OMX_IndexParamAudioPcm:
 {
 const OMX_AUDIO_PARAM_PCMMODETYPE *pcmMode =
 (const OMX_AUDIO_PARAM_PCMMODETYPE *) params;
 if (!isValidOMXParam(pcmMode)) {
 return false;
 }
            portIndex = pcmMode->nPortIndex;
 break;
 }

 case OMX_IndexParamAudioAac:
 {
 const OMX_AUDIO_PARAM_AACPROFILETYPE *aacMode =
 (const OMX_AUDIO_PARAM_AACPROFILETYPE *) params;
 if (!isValidOMXParam(aacMode)) {
 return false;
 }
            portIndex = aacMode->nPortIndex;
 break;
 }

 default:
 return false;
 }

    CHECK(portIndex < mPorts.size());

 return !mPorts.itemAt(portIndex).mDef.bEnabled;
}

bool SimpleSoftOMXComponent::isSetParameterAllowed(
        OMX_INDEXTYPE index, const OMX_PTR params) const {
 if (mState == OMX_StateLoaded) {
 return true;
 }

    OMX_U32 portIndex;

 switch (index) {
 case OMX_IndexParamPortDefinition:
 {
 const OMX_PARAM_PORTDEFINITIONTYPE *portDefs =
 (const OMX_PARAM_PORTDEFINITIONTYPE *) params;
 if (!isValidOMXParam(portDefs)) {
 return false;
 }
            portIndex = portDefs->nPortIndex;
 break;
 }

 case OMX_IndexParamAudioPcm:
 {
 const OMX_AUDIO_PARAM_PCMMODETYPE *pcmMode =
 (const OMX_AUDIO_PARAM_PCMMODETYPE *) params;
 if (!isValidOMXParam(pcmMode)) {
 return false;
 }
            portIndex = pcmMode->nPortIndex;
 break;
 }

 case OMX_IndexParamAudioAac:
 {
 const OMX_AUDIO_PARAM_AACPROFILETYPE *aacMode =
 (const OMX_AUDIO_PARAM_AACPROFILETYPE *) params;
 if (!isValidOMXParam(aacMode)) {
 return false;
 }
            portIndex = aacMode->nPortIndex;
 break;
 }

 default:
 return false;
 }

    CHECK(portIndex < mPorts.size());

 return !mPorts.itemAt(portIndex).mDef.bEnabled;
}
