From: Lukasz Kostyra Date: Wed, 11 Oct 2017 16:26:48 +0000 (+0200) Subject: teec: Fix temp memory allocation X-Git-Tag: submit/tizen/20171018.143448~3^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=31b6e54aba86ae2b3e975d5b79fb387fd12d15a7;p=platform%2Fcore%2Fsecurity%2Ftef-simulator.git teec: Fix temp memory allocation When allocating shared memory for temp memory reference in operation, TEECLib didn't set proper memory flag. This caused an error during operation pre-processing. Change-Id: I8b1fa13ac5d8feca1f596f514ab40e3f03d2198c --- diff --git a/TEECLib/src/teec_api.c b/TEECLib/src/teec_api.c index 172912b..a84aac7 100644 --- a/TEECLib/src/teec_api.c +++ b/TEECLib/src/teec_api.c @@ -318,6 +318,14 @@ static TEEC_Result preProcessOperation(TEEC_Session *session, sizeof(TEEC_SharedMemory)); tmpSharedMem[i]->size = operation->params[i].tmpref.size; tmpSharedMem[i]->buffer = operation->params[i].tmpref.buffer; + if (type == TEEC_MEMREF_TEMP_INPUT) { + tmpSharedMem[i]->flags = TEEC_MEM_INPUT; + } else if (type == TEEC_MEMREF_TEMP_OUTPUT) { + tmpSharedMem[i]->flags = TEEC_MEM_OUTPUT; + } else if (type == TEEC_MEMREF_TEMP_INOUT) { + tmpSharedMem[i]->flags = TEEC_MEM_INPUT | TEEC_MEM_OUTPUT; + } + result = TEEC_RegisterSharedMemory( ((TEEC_SessionImp*)session->imp)->context, tmpSharedMem[i]); if (result != TEEC_SUCCESS) { @@ -329,14 +337,8 @@ static TEEC_Result preProcessOperation(TEEC_Session *session, } return result; } - if (type == TEEC_MEMREF_TEMP_INPUT) { - tmpSharedMem[i]->flags = TEEC_MEM_INPUT; - memcpy(((TEEC_SharedMemoryImp*)tmpSharedMem[i]->imp)->allocPtr, - tmpSharedMem[i]->buffer, tmpSharedMem[i]->size); - } else if (type == TEEC_MEMREF_TEMP_OUTPUT) - tmpSharedMem[i]->flags = TEEC_MEM_OUTPUT; - else { - tmpSharedMem[i]->flags = TEEC_MEM_INPUT | TEEC_MEM_OUTPUT; + + if (type & TEEC_MEMREF_TEMP_INPUT) { memcpy(((TEEC_SharedMemoryImp*)tmpSharedMem[i]->imp)->allocPtr, tmpSharedMem[i]->buffer, tmpSharedMem[i]->size); }