mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-07-02 12:02:47 -05:00
Control of 'addr' is now handed over to {platform_,}new_connection() and
sk_new() on invocation; these functions become responsible for (eventually)
freeing it. The caller must not do anything with 'addr' after it's been passed
in. (Ick.)
Why:
A SOCKS5 crash appears to have been caused by overzealous freeing of
a SockAddr (ssh.c:1.257 [r2492]), which for proxied connections is
squirreled away long-term (and this can't easily be avoided).
It would have been nice to make a copy of the SockAddr, in case the caller has
a use for it, but one of the implementations (uxnet.c) hides a "struct
addrinfo" in there, and we have no defined way to duplicate those. (None of the
current callers _do_ have a further use for the SockAddr.)
As far as I can tell, everything _except_ proxying only needs addr for the
duration of the call, so sk_addr_free()s immediately. If I'm mistaken, it
should at least be easier to find the offending free()...
[originally from svn r3383]
[r2492 == bdd6633970
]
This commit is contained in:
5
proxy.c
5
proxy.c
@ -90,6 +90,7 @@ static void sk_proxy_close (Socket s)
|
||||
Proxy_Socket ps = (Proxy_Socket) s;
|
||||
|
||||
sk_close(ps->sub_socket);
|
||||
sk_addr_free(ps->remote_addr);
|
||||
sfree(ps);
|
||||
}
|
||||
|
||||
@ -391,7 +392,7 @@ Socket new_connection(SockAddr addr, char *hostname,
|
||||
ret->fn = &socket_fn_table;
|
||||
ret->cfg = *cfg; /* STRUCTURE COPY */
|
||||
ret->plug = plug;
|
||||
ret->remote_addr = addr;
|
||||
ret->remote_addr = addr; /* will need to be freed on close */
|
||||
ret->remote_port = port;
|
||||
|
||||
ret->error = NULL;
|
||||
@ -443,8 +444,6 @@ Socket new_connection(SockAddr addr, char *hostname,
|
||||
if (sk_socket_error(ret->sub_socket) != NULL)
|
||||
return (Socket) ret;
|
||||
|
||||
sk_addr_free(proxy_addr);
|
||||
|
||||
/* start the proxy negotiation process... */
|
||||
sk_set_frozen(ret->sub_socket, 0);
|
||||
ret->negotiate(ret, PROXY_CHANGE_NEW);
|
||||
|
Reference in New Issue
Block a user