From 2fcec3db4bc02b258365222421da2a0c3682ba57 Mon Sep 17 00:00:00 2001 From: Carsten Haitzler Date: Fri, 20 Jul 2012 09:40:03 +0000 Subject: [PATCH] fix bug in example of assuming 0 termination of "data" as its not a string. SVN revision: 74226 --- legacy/ecore/src/examples/ecore_exe_example.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/legacy/ecore/src/examples/ecore_exe_example.c b/legacy/ecore/src/examples/ecore_exe_example.c index 67c5fd0ae7..42beddbb94 100644 --- a/legacy/ecore/src/examples/ecore_exe_example.c +++ b/legacy/ecore/src/examples/ecore_exe_example.c @@ -12,8 +12,17 @@ static Eina_Bool _msg_from_child_handler(void *data, int type, void *event) { Ecore_Exe_Event_Data *dataFromProcess = (Ecore_Exe_Event_Data *)event; - char *msg = (char *)dataFromProcess->data; + char msg[BUFFER_SIZE]; + if (dataFromProcess->size >= (BUFFER_SIZE - 1)) + { + fprintf(stdout, "Data too big for bugger. error\n"); + return ECORE_CALLBACK_DONE; + } + + strncpy(msg, dataFromProcess->data, dataFromProcess->size); + msg[dataFromProcess->size = 0; + if (strcmp(msg, "quit") == 0) { fprintf(stdout, "My child said to me, QUIT!\n");