]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: lua: ensure large proxy IDs can be represented
authorWilly Tarreau <w@1wt.eu>
Sun, 6 May 2018 12:50:09 +0000 (14:50 +0200)
committerWilly Tarreau <w@1wt.eu>
Sun, 6 May 2018 12:50:09 +0000 (14:50 +0200)
In function hlua_fcn_new_proxy() too small a buffer was passed to
snprintf(), resulting in large proxy or listener IDs to make
snprintf() fail. It is unlikely to meet this case but let's fix it
anyway.

This fix must be backported to all stable branches where it applies.

src/hlua_fcn.c

index 5062a196f3d1e79a960aa10a10a287ff22126193..83153c5cdb78eebb81b4a22c626287d3f854e981 100644 (file)
@@ -838,7 +838,7 @@ int hlua_fcn_new_proxy(lua_State *L, struct proxy *px)
        struct server *srv;
        struct listener *lst;
        int lid;
-       char buffer[10];
+       char buffer[17];
 
        lua_newtable(L);
 
@@ -878,7 +878,7 @@ int hlua_fcn_new_proxy(lua_State *L, struct proxy *px)
                if (lst->name)
                        lua_pushstring(L, lst->name);
                else {
-                       snprintf(buffer, 10, "sock-%d", lid);
+                       snprintf(buffer, sizeof(buffer), "sock-%d", lid);
                        lid++;
                        lua_pushstring(L, buffer);
                }