diff options
-rw-r--r-- | host/main.c | 8 |
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, |