From d15237314daba479fd6cc854a4fe3fe3586e26fd Mon Sep 17 00:00:00 2001 From: raster 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. git-svn-id: http://svn.enlightenment.org/svn/e/trunk/ecore@74226 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33 --- src/examples/ecore_exe_example.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/examples/ecore_exe_example.c b/src/examples/ecore_exe_example.c index 67c5fd0..42beddb 100644 --- a/src/examples/ecore_exe_example.c +++ b/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"); -- 2.7.4