]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MEDIUM: lua: properly set the target on the connection
authorWilly Tarreau <w@1wt.eu>
Sat, 26 Sep 2015 15:51:09 +0000 (17:51 +0200)
committerWilly Tarreau <w@1wt.eu>
Sat, 26 Sep 2015 15:56:23 +0000 (17:56 +0200)
Not having the target set on the connection causes it to be released
at the last moment, and the destination address to randomly be valid
depending on the data found in the memory at this moment. In practice
it works as long as memory poisonning is disabled. The deep reason is
that connect_server() doesn't expect to be called with SF_ADDR_SET and
an existing connection with !reuse. This causes the release of the
connection, its reallocation (!reuse), and taking the address from the
newly allocated connection. This should certainly be improved.

src/hlua.c

index d2a2110783cab543f3ef631825f78941c8228a95..30e294fd049d29a5cf9dd4d25ce82383bf1a3828 100644 (file)
@@ -2192,6 +2192,9 @@ __LJMP static int hlua_socket_connect(struct lua_State *L)
        if (!conn)
                WILL_LJMP(luaL_error(L, "connect: internal error"));
 
+       /* needed for the connection not to be closed */
+       conn->target = socket->s->target;
+
        /* Parse ip address. */
        conn->addr.to.ss_family = AF_UNSPEC;
        if (!str2ip2(ip, &conn->addr.to, 0))