]> git.e2factory.org Git - e2factory.git/commitdiff
do_execvp: Allocate space for the terminating NULL pointer
authorTobias Ulmer <tu@emlix.com>
Fri, 29 Nov 2013 13:51:41 +0000 (14:51 +0100)
committerTobias Ulmer <tu@emlix.com>
Wed, 16 Nov 2016 14:41:17 +0000 (15:41 +0100)
Signed-off-by: Tobias Ulmer <tu@emlix.com>
generic/le2lib.c

index 8f7ce6f68268f330670e53e54e2e3fd83bde27ca..2105173e8ee0cfb632258294562c490088f7b9f5 100644 (file)
@@ -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));