From: Tobias Ulmer Date: Fri, 29 Nov 2013 13:51:41 +0000 (+0100) Subject: do_execvp: Allocate space for the terminating NULL pointer X-Git-Tag: e2factory-2.3.15rc1~324 X-Git-Url: https://git.e2factory.org/?a=commitdiff_plain;h=bc409805d261e4eb82cbbcfb5d83f6da32086287;p=e2factory.git do_execvp: Allocate space for the terminating NULL pointer Signed-off-by: Tobias Ulmer --- diff --git a/generic/le2lib.c b/generic/le2lib.c index 8f7ce6f..2105173 100644 --- a/generic/le2lib.c +++ b/generic/le2lib.c @@ -429,7 +429,7 @@ do_execvp(lua_State *L) return 2; } - argv = malloc(argc * sizeof(char *)); + argv = malloc((argc+1) * sizeof(char *)); if (argv == NULL) { lua_pushboolean(L, 0); lua_pushstring(L, "do_execvp: 1+ argv arguments required"); @@ -442,11 +442,9 @@ do_execvp(lua_State *L) } argv[i] = NULL; - - execvp(file, argv); - /* If it returns at all something is wrong */ + /* If it returns, something is wrong */ free(argv); lua_pushboolean(L, 0); lua_pushstring(L, strerror(errno));