]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: hlua: use a local buffer to format the socket addresses
authorWilly Tarreau <w@1wt.eu>
Thu, 6 Aug 2026 07:38:41 +0000 (09:38 +0200)
committerWilly Tarreau <w@1wt.eu>
Thu, 6 Aug 2026 16:05:45 +0000 (18:05 +0200)
hlua_socket_info() formats the peer or local address of a Lua socket into
a function-static buffer shared by all threads. But there's no reason for
this buffer to be static, and it can cause inter-thread corruption. Let's
just drop the static modifier so that the address lies in the stack.

It can be backported to all versions since it's been there since 1.6
when sockets were introduced to Lua.

Reported-by: Claude (ANT-2026-W66XVDTK)
src/hlua.c

index 38f82182e61b2f52dbd8cd32c1785a1200d6890b..1f62dc53e98727aefd0b39141683c10bc52b671d 100644 (file)
@@ -3301,7 +3301,7 @@ static int hlua_socket_send(struct lua_State *L)
 #define SOCKET_INFO_MAX_LEN sizeof("[0000:0000:0000:0000:0000:0000:0000:0000]:12345")
 __LJMP static inline int hlua_socket_info(struct lua_State *L, const struct sockaddr_storage *addr)
 {
-       static char buffer[SOCKET_INFO_MAX_LEN];
+       char buffer[SOCKET_INFO_MAX_LEN];
        int ret;
        int len;
        char *p;