summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIlias Apalodimas <ilias.apalodimas@linaro.org>2018-07-05 12:12:38 +0300
committerIlias Apalodimas <ilias.apalodimas@linaro.org>2018-07-05 12:12:38 +0300
commit88bc9d3a15ee5ff029f3e264284c9b13ecb809fa (patch)
tree2d25da76198c2f7128553ac6bf3cd6cda56ab60c
parent34996aa48bb9979010b84f39858df4774d970e4f (diff)
bug fix on memory allocation sizeHEADmaster
Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
-rw-r--r--host/main.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/host/main.c b/host/main.c
index 8ea7be0..ffd8b1a 100644
--- a/host/main.c
+++ b/host/main.c
@@ -48,6 +48,10 @@ int main(int argc, char *argv[])
.buffer = NULL,
};
+ if (argv[1] == '\0') {
+ printf("No log message specified\n");
+ return 0;
+ }
/* Initialize a context connecting us to the TEE */
res = TEEC_InitializeContext(NULL, &ctx);
if (res != TEEC_SUCCESS)
@@ -74,13 +78,13 @@ int main(int argc, char *argv[])
op.paramTypes = TEEC_PARAM_TYPES(TEEC_MEMREF_WHOLE, TEEC_NONE,
TEEC_NONE, TEEC_NONE);
+ buf_shm.size = strlen(argv[1]) + 1;
res = TEEC_AllocateSharedMemory(&ctx, &buf_shm);
if (res != TEEC_SUCCESS) {
errx(1, "TEEC_AllocateSharedMemory failed");
return -1;
}
- buf_shm.size = strlen(argv[1]) + 1;
- memcpy(buf_shm.buffer, argv[1], buf_shm.size);
+ strncpy(buf_shm.buffer, argv[1], buf_shm.size);
op.params[0].memref.parent = &buf_shm;
res = TEEC_InvokeCommand(&sess, TA_LOGGER_WRITE, &op,