BUG/MEDIUM: lua: properly set the target on the connection

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.
This commit is contained in:
Willy Tarreau 2015-09-26 17:51:09 +02:00
parent 9af89f7905
commit 3adac08849

View 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))