]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: lua: lua-load doesn't check its parameters
authorThierry Fournier <thierry.fournier@ozon.io>
Sun, 29 Nov 2020 00:06:24 +0000 (01:06 +0100)
committerWilly Tarreau <w@1wt.eu>
Wed, 2 Dec 2020 08:42:43 +0000 (09:42 +0100)
"lua-load" doesn't check if the expected parameter is present. It tries to
open() directly the argument at second position. So if the filename is
omitted, it tries to load an empty filename.

This patch could be backported until 1.8

src/hlua.c

index 1ecf0c165186f50f80c5608ec1edce5327f5a567..49db0f36ec7fc8aa834970bd871b6e1fdb5379d4 100644 (file)
@@ -7986,6 +7986,11 @@ static int hlua_load(char **args, int section_type, struct proxy *curpx,
 {
        int error;
 
+       if (*(args[1]) == 0) {
+               memprintf(err, "'%s' expects a file name as parameter.\n", args[0]);
+               return -1;
+       }
+
        /* Just load and compile the file. */
        error = luaL_loadfile(gL.T, args[1]);
        if (error) {