mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-01-10 01:48:00 +00:00
Remove 'calling_back' parameter from plug_closing.
It was totally unused. No implementation of the 'closing' method in a
Plug vtable was checking it for any reason at all, except for
ProxySocket which captured it from its client in order to pass on to
its server (which, perhaps after further iterations of ProxySocket,
would have ended up ignoring it similarly). And every caller of
plug_closing set it to 0 (aka false), except for the one in sshproxy.c
which passed true (but it would have made no difference to anyone).
The comment in network.h refers to a FIXME comment which was in
try_send() when that code was written (see winnet.c in commit
7b0e082700
). That FIXME is long gone, replaced by a use of a
toplevel callback. So I think the aim must have been to avoid
re-entrancy when sk_write called try_send which encountered a socket
error and called back to plug_closing - but that's long since fixed by
other means now.
This commit is contained in:
parent
b13f3d079b
commit
d42f1fe96d
10
cproxy.c
10
cproxy.c
@ -67,13 +67,13 @@ int proxy_socks5_handlechap (ProxySocket *p)
|
|||||||
if (data[0] != 0x01) {
|
if (data[0] != 0x01) {
|
||||||
plug_closing(p->plug, "Proxy error: SOCKS proxy wants"
|
plug_closing(p->plug, "Proxy error: SOCKS proxy wants"
|
||||||
" a different CHAP version",
|
" a different CHAP version",
|
||||||
PROXY_ERROR_GENERAL, 0);
|
PROXY_ERROR_GENERAL);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
if (data[1] == 0x00) {
|
if (data[1] == 0x00) {
|
||||||
plug_closing(p->plug, "Proxy error: SOCKS proxy won't"
|
plug_closing(p->plug, "Proxy error: SOCKS proxy won't"
|
||||||
" negotiate CHAP with us",
|
" negotiate CHAP with us",
|
||||||
PROXY_ERROR_GENERAL, 0);
|
PROXY_ERROR_GENERAL);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
p->chap_num_attributes = data[1];
|
p->chap_num_attributes = data[1];
|
||||||
@ -105,7 +105,7 @@ int proxy_socks5_handlechap (ProxySocket *p)
|
|||||||
else {
|
else {
|
||||||
plug_closing(p->plug, "Proxy error: SOCKS proxy"
|
plug_closing(p->plug, "Proxy error: SOCKS proxy"
|
||||||
" refused CHAP authentication",
|
" refused CHAP authentication",
|
||||||
PROXY_ERROR_GENERAL, 0);
|
PROXY_ERROR_GENERAL);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -125,7 +125,7 @@ int proxy_socks5_handlechap (ProxySocket *p)
|
|||||||
plug_closing(p->plug, "Proxy error: Server chose "
|
plug_closing(p->plug, "Proxy error: Server chose "
|
||||||
"CHAP of other than HMAC-MD5 but we "
|
"CHAP of other than HMAC-MD5 but we "
|
||||||
"didn't offer it!",
|
"didn't offer it!",
|
||||||
PROXY_ERROR_GENERAL, 0);
|
PROXY_ERROR_GENERAL);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -174,6 +174,6 @@ int proxy_socks5_selectchap(ProxySocket *p)
|
|||||||
} else
|
} else
|
||||||
plug_closing(p->plug, "Proxy error: Server chose "
|
plug_closing(p->plug, "Proxy error: Server chose "
|
||||||
"CHAP authentication but we didn't offer it!",
|
"CHAP authentication but we didn't offer it!",
|
||||||
PROXY_ERROR_GENERAL, 0);
|
PROXY_ERROR_GENERAL);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
10
network.h
10
network.h
@ -87,7 +87,7 @@ struct PlugVtable {
|
|||||||
* the logged events.
|
* the logged events.
|
||||||
*/
|
*/
|
||||||
void (*closing)
|
void (*closing)
|
||||||
(Plug *p, const char *error_msg, int error_code, bool calling_back);
|
(Plug *p, const char *error_msg, int error_code);
|
||||||
/* error_msg is NULL iff it is not an error (ie it closed normally) */
|
/* error_msg is NULL iff it is not an error (ie it closed normally) */
|
||||||
/* calling_back != 0 iff there is a Plug function */
|
/* calling_back != 0 iff there is a Plug function */
|
||||||
/* currently running (would cure the fixme in try_send()) */
|
/* currently running (would cure the fixme in try_send()) */
|
||||||
@ -214,9 +214,8 @@ static inline void sk_write_eof(Socket *s)
|
|||||||
static inline void plug_log(
|
static inline void plug_log(
|
||||||
Plug *p, int type, SockAddr *addr, int port, const char *msg, int code)
|
Plug *p, int type, SockAddr *addr, int port, const char *msg, int code)
|
||||||
{ p->vt->log(p, type, addr, port, msg, code); }
|
{ p->vt->log(p, type, addr, port, msg, code); }
|
||||||
static inline void plug_closing(
|
static inline void plug_closing(Plug *p, const char *msg, int code)
|
||||||
Plug *p, const char *msg, int code, bool calling_back)
|
{ p->vt->closing(p, msg, code); }
|
||||||
{ p->vt->closing(p, msg, code, calling_back); }
|
|
||||||
static inline void plug_receive(Plug *p, int urg, const char *data, size_t len)
|
static inline void plug_receive(Plug *p, int urg, const char *data, size_t len)
|
||||||
{ p->vt->receive(p, urg, data, len); }
|
{ p->vt->receive(p, urg, data, len); }
|
||||||
static inline void plug_sent (Plug *p, size_t bufsize)
|
static inline void plug_sent (Plug *p, size_t bufsize)
|
||||||
@ -341,8 +340,7 @@ extern Plug *const nullplug;
|
|||||||
*/
|
*/
|
||||||
void nullplug_log(Plug *plug, PlugLogType type, SockAddr *addr,
|
void nullplug_log(Plug *plug, PlugLogType type, SockAddr *addr,
|
||||||
int port, const char *err_msg, int err_code);
|
int port, const char *err_msg, int err_code);
|
||||||
void nullplug_closing(Plug *plug, const char *error_msg, int error_code,
|
void nullplug_closing(Plug *plug, const char *error_msg, int error_code);
|
||||||
bool calling_back);
|
|
||||||
void nullplug_receive(Plug *plug, int urgent, const char *data, size_t len);
|
void nullplug_receive(Plug *plug, int urgent, const char *data, size_t len);
|
||||||
void nullplug_sent(Plug *plug, size_t bufsize);
|
void nullplug_sent(Plug *plug, size_t bufsize);
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@ int proxy_socks5_handlechap (ProxySocket *p)
|
|||||||
|
|
||||||
plug_closing(p->plug, "Proxy error: Trying to handle a SOCKS5 CHAP request"
|
plug_closing(p->plug, "Proxy error: Trying to handle a SOCKS5 CHAP request"
|
||||||
" in telnet-only build",
|
" in telnet-only build",
|
||||||
PROXY_ERROR_GENERAL, 0);
|
PROXY_ERROR_GENERAL);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -30,6 +30,6 @@ int proxy_socks5_selectchap(ProxySocket *p)
|
|||||||
{
|
{
|
||||||
plug_closing(p->plug, "Proxy error: Trying to handle a SOCKS5 CHAP request"
|
plug_closing(p->plug, "Proxy error: Trying to handle a SOCKS5 CHAP request"
|
||||||
" in telnet-only build",
|
" in telnet-only build",
|
||||||
PROXY_ERROR_GENERAL, 0);
|
PROXY_ERROR_GENERAL);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -12,8 +12,7 @@ void nullplug_log(Plug *plug, PlugLogType type, SockAddr *addr,
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void nullplug_closing(Plug *plug, const char *error_msg, int error_code,
|
void nullplug_closing(Plug *plug, const char *error_msg, int error_code)
|
||||||
bool calling_back)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -69,8 +69,7 @@ static void raw_check_close(Raw *raw)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void raw_closing(Plug *plug, const char *error_msg, int error_code,
|
static void raw_closing(Plug *plug, const char *error_msg, int error_code)
|
||||||
bool calling_back)
|
|
||||||
{
|
{
|
||||||
Raw *raw = container_of(plug, Raw, plug);
|
Raw *raw = container_of(plug, Raw, plug);
|
||||||
|
|
||||||
|
@ -89,8 +89,7 @@ static void rlogin_log(Plug *plug, PlugLogType type, SockAddr *addr, int port,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void rlogin_closing(Plug *plug, const char *error_msg, int error_code,
|
static void rlogin_closing(Plug *plug, const char *error_msg, int error_code)
|
||||||
bool calling_back)
|
|
||||||
{
|
{
|
||||||
Rlogin *rlogin = container_of(plug, Rlogin, plug);
|
Rlogin *rlogin = container_of(plug, Rlogin, plug);
|
||||||
|
|
||||||
|
@ -577,8 +577,7 @@ static void supdup_log(Plug *plug, PlugLogType type, SockAddr *addr, int port,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void supdup_closing(Plug *plug, const char *error_msg, int error_code,
|
static void supdup_closing(Plug *plug, const char *error_msg, int error_code)
|
||||||
bool calling_back)
|
|
||||||
{
|
{
|
||||||
Supdup *supdup = container_of(plug, Supdup, plug);
|
Supdup *supdup = container_of(plug, Supdup, plug);
|
||||||
|
|
||||||
|
@ -639,8 +639,7 @@ static void telnet_log(Plug *plug, PlugLogType type, SockAddr *addr, int port,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void telnet_closing(Plug *plug, const char *error_msg, int error_code,
|
static void telnet_closing(Plug *plug, const char *error_msg, int error_code)
|
||||||
bool calling_back)
|
|
||||||
{
|
{
|
||||||
Telnet *telnet = container_of(plug, Telnet, plug);
|
Telnet *telnet = container_of(plug, Telnet, plug);
|
||||||
|
|
||||||
|
@ -1464,7 +1464,7 @@ struct pageant_conn_state {
|
|||||||
};
|
};
|
||||||
|
|
||||||
static void pageant_conn_closing(Plug *plug, const char *error_msg,
|
static void pageant_conn_closing(Plug *plug, const char *error_msg,
|
||||||
int error_code, bool calling_back)
|
int error_code)
|
||||||
{
|
{
|
||||||
struct pageant_conn_state *pc = container_of(
|
struct pageant_conn_state *pc = container_of(
|
||||||
plug, struct pageant_conn_state, plug);
|
plug, struct pageant_conn_state, plug);
|
||||||
@ -1611,7 +1611,7 @@ struct pageant_listen_state {
|
|||||||
};
|
};
|
||||||
|
|
||||||
static void pageant_listen_closing(Plug *plug, const char *error_msg,
|
static void pageant_listen_closing(Plug *plug, const char *error_msg,
|
||||||
int error_code, bool calling_back)
|
int error_code)
|
||||||
{
|
{
|
||||||
struct pageant_listen_state *pl = container_of(
|
struct pageant_listen_state *pl = container_of(
|
||||||
plug, struct pageant_listen_state, plug);
|
plug, struct pageant_listen_state, plug);
|
||||||
|
56
proxy.c
56
proxy.c
@ -181,18 +181,16 @@ static void plug_proxy_log(Plug *plug, PlugLogType type, SockAddr *addr,
|
|||||||
plug_log(ps->plug, type, addr, port, error_msg, error_code);
|
plug_log(ps->plug, type, addr, port, error_msg, error_code);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void plug_proxy_closing (Plug *p, const char *error_msg,
|
static void plug_proxy_closing(Plug *p, const char *error_msg, int error_code)
|
||||||
int error_code, bool calling_back)
|
|
||||||
{
|
{
|
||||||
ProxySocket *ps = container_of(p, ProxySocket, plugimpl);
|
ProxySocket *ps = container_of(p, ProxySocket, plugimpl);
|
||||||
|
|
||||||
if (ps->state != PROXY_STATE_ACTIVE) {
|
if (ps->state != PROXY_STATE_ACTIVE) {
|
||||||
ps->closing_error_msg = error_msg;
|
ps->closing_error_msg = error_msg;
|
||||||
ps->closing_error_code = error_code;
|
ps->closing_error_code = error_code;
|
||||||
ps->closing_calling_back = calling_back;
|
|
||||||
ps->negotiate(ps, PROXY_CHANGE_CLOSING);
|
ps->negotiate(ps, PROXY_CHANGE_CLOSING);
|
||||||
} else {
|
} else {
|
||||||
plug_closing(ps->plug, error_msg, error_code, calling_back);
|
plug_closing(ps->plug, error_msg, error_code);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -617,8 +615,7 @@ int proxy_http_negotiate (ProxySocket *p, int change)
|
|||||||
* a socket close, then some error must have occurred. we'll
|
* a socket close, then some error must have occurred. we'll
|
||||||
* just pass those errors up to the backend.
|
* just pass those errors up to the backend.
|
||||||
*/
|
*/
|
||||||
plug_closing(p->plug, p->closing_error_msg, p->closing_error_code,
|
plug_closing(p->plug, p->closing_error_msg, p->closing_error_code);
|
||||||
p->closing_calling_back);
|
|
||||||
return 0; /* ignored */
|
return 0; /* ignored */
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -675,7 +672,7 @@ int proxy_http_negotiate (ProxySocket *p, int change)
|
|||||||
if (sscanf((char *)data, "HTTP/%i.%i %n",
|
if (sscanf((char *)data, "HTTP/%i.%i %n",
|
||||||
&maj_ver, &min_ver, &status) < 2 || status == -1) {
|
&maj_ver, &min_ver, &status) < 2 || status == -1) {
|
||||||
plug_closing(p->plug, "Proxy error: HTTP response was absent",
|
plug_closing(p->plug, "Proxy error: HTTP response was absent",
|
||||||
PROXY_ERROR_GENERAL, 0);
|
PROXY_ERROR_GENERAL);
|
||||||
sfree(data);
|
sfree(data);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@ -690,7 +687,7 @@ int proxy_http_negotiate (ProxySocket *p, int change)
|
|||||||
(data[eol-1] == '\r' || data[eol-1] == '\n'))
|
(data[eol-1] == '\r' || data[eol-1] == '\n'))
|
||||||
data[--eol] = '\0';
|
data[--eol] = '\0';
|
||||||
buf = dupprintf("Proxy error: %s", data+status);
|
buf = dupprintf("Proxy error: %s", data+status);
|
||||||
plug_closing(p->plug, buf, PROXY_ERROR_GENERAL, 0);
|
plug_closing(p->plug, buf, PROXY_ERROR_GENERAL);
|
||||||
sfree(buf);
|
sfree(buf);
|
||||||
sfree(data);
|
sfree(data);
|
||||||
return 1;
|
return 1;
|
||||||
@ -741,7 +738,7 @@ int proxy_http_negotiate (ProxySocket *p, int change)
|
|||||||
}
|
}
|
||||||
|
|
||||||
plug_closing(p->plug, "Proxy error: unexpected proxy error",
|
plug_closing(p->plug, "Proxy error: unexpected proxy error",
|
||||||
PROXY_ERROR_UNEXPECTED, 0);
|
PROXY_ERROR_UNEXPECTED);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -807,8 +804,7 @@ int proxy_socks4_negotiate (ProxySocket *p, int change)
|
|||||||
* a socket close, then some error must have occurred. we'll
|
* a socket close, then some error must have occurred. we'll
|
||||||
* just pass those errors up to the backend.
|
* just pass those errors up to the backend.
|
||||||
*/
|
*/
|
||||||
plug_closing(p->plug, p->closing_error_msg, p->closing_error_code,
|
plug_closing(p->plug, p->closing_error_msg, p->closing_error_code);
|
||||||
p->closing_calling_back);
|
|
||||||
return 0; /* ignored */
|
return 0; /* ignored */
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -860,7 +856,7 @@ int proxy_socks4_negotiate (ProxySocket *p, int change)
|
|||||||
if (data[0] != 0) {
|
if (data[0] != 0) {
|
||||||
plug_closing(p->plug, "Proxy error: SOCKS proxy responded with "
|
plug_closing(p->plug, "Proxy error: SOCKS proxy responded with "
|
||||||
"unexpected reply code version",
|
"unexpected reply code version",
|
||||||
PROXY_ERROR_GENERAL, 0);
|
PROXY_ERROR_GENERAL);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -869,16 +865,16 @@ int proxy_socks4_negotiate (ProxySocket *p, int change)
|
|||||||
switch (data[1]) {
|
switch (data[1]) {
|
||||||
case 92:
|
case 92:
|
||||||
plug_closing(p->plug, "Proxy error: SOCKS server wanted IDENTD on client",
|
plug_closing(p->plug, "Proxy error: SOCKS server wanted IDENTD on client",
|
||||||
PROXY_ERROR_GENERAL, 0);
|
PROXY_ERROR_GENERAL);
|
||||||
break;
|
break;
|
||||||
case 93:
|
case 93:
|
||||||
plug_closing(p->plug, "Proxy error: Username and IDENTD on client don't agree",
|
plug_closing(p->plug, "Proxy error: Username and IDENTD on client don't agree",
|
||||||
PROXY_ERROR_GENERAL, 0);
|
PROXY_ERROR_GENERAL);
|
||||||
break;
|
break;
|
||||||
case 91:
|
case 91:
|
||||||
default:
|
default:
|
||||||
plug_closing(p->plug, "Proxy error: Error while communicating with proxy",
|
plug_closing(p->plug, "Proxy error: Error while communicating with proxy",
|
||||||
PROXY_ERROR_GENERAL, 0);
|
PROXY_ERROR_GENERAL);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -895,7 +891,7 @@ int proxy_socks4_negotiate (ProxySocket *p, int change)
|
|||||||
}
|
}
|
||||||
|
|
||||||
plug_closing(p->plug, "Proxy error: unexpected proxy error",
|
plug_closing(p->plug, "Proxy error: unexpected proxy error",
|
||||||
PROXY_ERROR_UNEXPECTED, 0);
|
PROXY_ERROR_UNEXPECTED);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -951,8 +947,7 @@ int proxy_socks5_negotiate (ProxySocket *p, int change)
|
|||||||
* a socket close, then some error must have occurred. we'll
|
* a socket close, then some error must have occurred. we'll
|
||||||
* just pass those errors up to the backend.
|
* just pass those errors up to the backend.
|
||||||
*/
|
*/
|
||||||
plug_closing(p->plug, p->closing_error_msg, p->closing_error_code,
|
plug_closing(p->plug, p->closing_error_msg, p->closing_error_code);
|
||||||
p->closing_calling_back);
|
|
||||||
return 0; /* ignored */
|
return 0; /* ignored */
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1002,7 +997,7 @@ int proxy_socks5_negotiate (ProxySocket *p, int change)
|
|||||||
|
|
||||||
if (data[0] != 5) {
|
if (data[0] != 5) {
|
||||||
plug_closing(p->plug, "Proxy error: SOCKS proxy returned unexpected version",
|
plug_closing(p->plug, "Proxy error: SOCKS proxy returned unexpected version",
|
||||||
PROXY_ERROR_GENERAL, 0);
|
PROXY_ERROR_GENERAL);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1012,7 +1007,7 @@ int proxy_socks5_negotiate (ProxySocket *p, int change)
|
|||||||
else if (data[1] == 0x03) p->state = 6; /* CHAP authentication */
|
else if (data[1] == 0x03) p->state = 6; /* CHAP authentication */
|
||||||
else {
|
else {
|
||||||
plug_closing(p->plug, "Proxy error: SOCKS proxy did not accept our authentication",
|
plug_closing(p->plug, "Proxy error: SOCKS proxy did not accept our authentication",
|
||||||
PROXY_ERROR_GENERAL, 0);
|
PROXY_ERROR_GENERAL);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
bufchain_consume(&p->pending_input_data, 2);
|
bufchain_consume(&p->pending_input_data, 2);
|
||||||
@ -1037,7 +1032,7 @@ int proxy_socks5_negotiate (ProxySocket *p, int change)
|
|||||||
if (data[0] != 1) {
|
if (data[0] != 1) {
|
||||||
plug_closing(p->plug, "Proxy error: SOCKS password "
|
plug_closing(p->plug, "Proxy error: SOCKS password "
|
||||||
"subnegotiation contained wrong version number",
|
"subnegotiation contained wrong version number",
|
||||||
PROXY_ERROR_GENERAL, 0);
|
PROXY_ERROR_GENERAL);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1045,7 +1040,7 @@ int proxy_socks5_negotiate (ProxySocket *p, int change)
|
|||||||
|
|
||||||
plug_closing(p->plug, "Proxy error: SOCKS proxy refused"
|
plug_closing(p->plug, "Proxy error: SOCKS proxy refused"
|
||||||
" password authentication",
|
" password authentication",
|
||||||
PROXY_ERROR_GENERAL, 0);
|
PROXY_ERROR_GENERAL);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1148,7 +1143,7 @@ int proxy_socks5_negotiate (ProxySocket *p, int change)
|
|||||||
|
|
||||||
if (data[0] != 5) {
|
if (data[0] != 5) {
|
||||||
plug_closing(p->plug, "Proxy error: SOCKS proxy returned wrong version number",
|
plug_closing(p->plug, "Proxy error: SOCKS proxy returned wrong version number",
|
||||||
PROXY_ERROR_GENERAL, 0);
|
PROXY_ERROR_GENERAL);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1171,7 +1166,7 @@ int proxy_socks5_negotiate (ProxySocket *p, int change)
|
|||||||
data[1]);
|
data[1]);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
plug_closing(p->plug, buf, PROXY_ERROR_GENERAL, 0);
|
plug_closing(p->plug, buf, PROXY_ERROR_GENERAL);
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@ -1187,7 +1182,7 @@ int proxy_socks5_negotiate (ProxySocket *p, int change)
|
|||||||
default:
|
default:
|
||||||
plug_closing(p->plug, "Proxy error: SOCKS proxy returned "
|
plug_closing(p->plug, "Proxy error: SOCKS proxy returned "
|
||||||
"unrecognised address format",
|
"unrecognised address format",
|
||||||
PROXY_ERROR_GENERAL, 0);
|
PROXY_ERROR_GENERAL);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
if (bufchain_size(&p->pending_input_data) < len)
|
if (bufchain_size(&p->pending_input_data) < len)
|
||||||
@ -1202,7 +1197,7 @@ int proxy_socks5_negotiate (ProxySocket *p, int change)
|
|||||||
if (p->state == 4) {
|
if (p->state == 4) {
|
||||||
/* TODO: Handle GSSAPI authentication */
|
/* TODO: Handle GSSAPI authentication */
|
||||||
plug_closing(p->plug, "Proxy error: We don't support GSSAPI authentication",
|
plug_closing(p->plug, "Proxy error: We don't support GSSAPI authentication",
|
||||||
PROXY_ERROR_GENERAL, 0);
|
PROXY_ERROR_GENERAL);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1231,7 +1226,7 @@ int proxy_socks5_negotiate (ProxySocket *p, int change)
|
|||||||
plug_closing(p->plug, "Proxy error: Server chose "
|
plug_closing(p->plug, "Proxy error: Server chose "
|
||||||
"username/password authentication but we "
|
"username/password authentication but we "
|
||||||
"didn't offer it!",
|
"didn't offer it!",
|
||||||
PROXY_ERROR_GENERAL, 0);
|
PROXY_ERROR_GENERAL);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1244,7 +1239,7 @@ int proxy_socks5_negotiate (ProxySocket *p, int change)
|
|||||||
}
|
}
|
||||||
|
|
||||||
plug_closing(p->plug, "Proxy error: Unexpected proxy error",
|
plug_closing(p->plug, "Proxy error: Unexpected proxy error",
|
||||||
PROXY_ERROR_UNEXPECTED, 0);
|
PROXY_ERROR_UNEXPECTED);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1479,8 +1474,7 @@ int proxy_telnet_negotiate (ProxySocket *p, int change)
|
|||||||
* a socket close, then some error must have occurred. we'll
|
* a socket close, then some error must have occurred. we'll
|
||||||
* just pass those errors up to the backend.
|
* just pass those errors up to the backend.
|
||||||
*/
|
*/
|
||||||
plug_closing(p->plug, p->closing_error_msg, p->closing_error_code,
|
plug_closing(p->plug, p->closing_error_msg, p->closing_error_code);
|
||||||
p->closing_calling_back);
|
|
||||||
return 0; /* ignored */
|
return 0; /* ignored */
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1516,6 +1510,6 @@ int proxy_telnet_negotiate (ProxySocket *p, int change)
|
|||||||
}
|
}
|
||||||
|
|
||||||
plug_closing(p->plug, "Proxy error: Unexpected proxy error",
|
plug_closing(p->plug, "Proxy error: Unexpected proxy error",
|
||||||
PROXY_ERROR_UNEXPECTED, 0);
|
PROXY_ERROR_UNEXPECTED);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
1
proxy.h
1
proxy.h
@ -63,7 +63,6 @@ struct ProxySocket {
|
|||||||
/* closing */
|
/* closing */
|
||||||
const char *closing_error_msg;
|
const char *closing_error_msg;
|
||||||
int closing_error_code;
|
int closing_error_code;
|
||||||
bool closing_calling_back;
|
|
||||||
|
|
||||||
/* receive */
|
/* receive */
|
||||||
bool receive_urgent;
|
bool receive_urgent;
|
||||||
|
4
psocks.c
4
psocks.c
@ -95,7 +95,7 @@ static const SshChannelVtable psocks_scvt = {
|
|||||||
static void psocks_plug_log(Plug *p, PlugLogType type, SockAddr *addr,
|
static void psocks_plug_log(Plug *p, PlugLogType type, SockAddr *addr,
|
||||||
int port, const char *error_msg, int error_code);
|
int port, const char *error_msg, int error_code);
|
||||||
static void psocks_plug_closing(Plug *p, const char *error_msg,
|
static void psocks_plug_closing(Plug *p, const char *error_msg,
|
||||||
int error_code, bool calling_back);
|
int error_code);
|
||||||
static void psocks_plug_receive(Plug *p, int urgent,
|
static void psocks_plug_receive(Plug *p, int urgent,
|
||||||
const char *data, size_t len);
|
const char *data, size_t len);
|
||||||
static void psocks_plug_sent(Plug *p, size_t bufsize);
|
static void psocks_plug_sent(Plug *p, size_t bufsize);
|
||||||
@ -355,7 +355,7 @@ static void psocks_plug_log(Plug *plug, PlugLogType type, SockAddr *addr,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void psocks_plug_closing(Plug *plug, const char *error_msg,
|
static void psocks_plug_closing(Plug *plug, const char *error_msg,
|
||||||
int error_code, bool calling_back)
|
int error_code)
|
||||||
{
|
{
|
||||||
psocks_connection *conn = container_of(plug, psocks_connection, plug);
|
psocks_connection *conn = container_of(plug, psocks_connection, plug);
|
||||||
if (conn->connecting) {
|
if (conn->connecting) {
|
||||||
|
@ -109,8 +109,7 @@ static void pfl_log(Plug *plug, PlugLogType type, SockAddr *addr, int port,
|
|||||||
|
|
||||||
static void pfd_close(struct PortForwarding *pf);
|
static void pfd_close(struct PortForwarding *pf);
|
||||||
|
|
||||||
static void pfd_closing(Plug *plug, const char *error_msg, int error_code,
|
static void pfd_closing(Plug *plug, const char *error_msg, int error_code)
|
||||||
bool calling_back)
|
|
||||||
{
|
{
|
||||||
struct PortForwarding *pf =
|
struct PortForwarding *pf =
|
||||||
container_of(plug, struct PortForwarding, plug);
|
container_of(plug, struct PortForwarding, plug);
|
||||||
@ -142,8 +141,7 @@ static void pfd_closing(Plug *plug, const char *error_msg, int error_code,
|
|||||||
|
|
||||||
static void pfl_terminate(struct PortListener *pl);
|
static void pfl_terminate(struct PortListener *pl);
|
||||||
|
|
||||||
static void pfl_closing(Plug *plug, const char *error_msg, int error_code,
|
static void pfl_closing(Plug *plug, const char *error_msg, int error_code)
|
||||||
bool calling_back)
|
|
||||||
{
|
{
|
||||||
struct PortListener *pl = (struct PortListener *) plug;
|
struct PortListener *pl = (struct PortListener *) plug;
|
||||||
pfl_terminate(pl);
|
pfl_terminate(pl);
|
||||||
|
@ -139,8 +139,7 @@ static void server_socket_log(Plug *plug, PlugLogType type, SockAddr *addr,
|
|||||||
/* FIXME */
|
/* FIXME */
|
||||||
}
|
}
|
||||||
|
|
||||||
static void server_closing(Plug *plug, const char *error_msg, int error_code,
|
static void server_closing(Plug *plug, const char *error_msg, int error_code)
|
||||||
bool calling_back)
|
|
||||||
{
|
{
|
||||||
server *srv = container_of(plug, server, plug);
|
server *srv = container_of(plug, server, plug);
|
||||||
if (error_msg) {
|
if (error_msg) {
|
||||||
|
@ -366,8 +366,7 @@ bool sesschan_run_subsystem(Channel *chan, ptrlen subsys)
|
|||||||
static void fwd_log(Plug *plug, PlugLogType type, SockAddr *addr, int port,
|
static void fwd_log(Plug *plug, PlugLogType type, SockAddr *addr, int port,
|
||||||
const char *error_msg, int error_code)
|
const char *error_msg, int error_code)
|
||||||
{ /* don't expect any weirdnesses from a listening socket */ }
|
{ /* don't expect any weirdnesses from a listening socket */ }
|
||||||
static void fwd_closing(Plug *plug, const char *error_msg, int error_code,
|
static void fwd_closing(Plug *plug, const char *error_msg, int error_code)
|
||||||
bool calling_back)
|
|
||||||
{ /* not here, either */ }
|
{ /* not here, either */ }
|
||||||
|
|
||||||
static int xfwd_accepting(Plug *p, accept_fn_t constructor, accept_ctx_t ctx)
|
static int xfwd_accepting(Plug *p, accept_fn_t constructor, accept_ctx_t ctx)
|
||||||
|
@ -937,8 +937,7 @@ static void share_disconnect(struct ssh_sharing_connstate *cs,
|
|||||||
share_begin_cleanup(cs);
|
share_begin_cleanup(cs);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void share_closing(Plug *plug, const char *error_msg, int error_code,
|
static void share_closing(Plug *plug, const char *error_msg, int error_code)
|
||||||
bool calling_back)
|
|
||||||
{
|
{
|
||||||
struct ssh_sharing_connstate *cs = container_of(
|
struct ssh_sharing_connstate *cs = container_of(
|
||||||
plug, struct ssh_sharing_connstate, plug);
|
plug, struct ssh_sharing_connstate, plug);
|
||||||
@ -1846,7 +1845,7 @@ static void share_sent(Plug *plug, size_t bufsize)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void share_listen_closing(Plug *plug, const char *error_msg,
|
static void share_listen_closing(Plug *plug, const char *error_msg,
|
||||||
int error_code, bool calling_back)
|
int error_code)
|
||||||
{
|
{
|
||||||
ssh_sharing_state *sharestate =
|
ssh_sharing_state *sharestate =
|
||||||
container_of(plug, ssh_sharing_state, plug);
|
container_of(plug, ssh_sharing_state, plug);
|
||||||
|
@ -609,8 +609,7 @@ static void ssh_socket_log(Plug *plug, PlugLogType type, SockAddr *addr,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ssh_closing(Plug *plug, const char *error_msg, int error_code,
|
static void ssh_closing(Plug *plug, const char *error_msg, int error_code)
|
||||||
bool calling_back)
|
|
||||||
{
|
{
|
||||||
Ssh *ssh = container_of(plug, Ssh, plug);
|
Ssh *ssh = container_of(plug, Ssh, plug);
|
||||||
if (error_msg) {
|
if (error_msg) {
|
||||||
|
@ -267,8 +267,7 @@ static void x11_log(Plug *p, PlugLogType type, SockAddr *addr, int port,
|
|||||||
static void x11_send_init_error(struct X11Connection *conn,
|
static void x11_send_init_error(struct X11Connection *conn,
|
||||||
const char *err_message);
|
const char *err_message);
|
||||||
|
|
||||||
static void x11_closing(Plug *plug, const char *error_msg, int error_code,
|
static void x11_closing(Plug *plug, const char *error_msg, int error_code)
|
||||||
bool calling_back)
|
|
||||||
{
|
{
|
||||||
struct X11Connection *xconn = container_of(
|
struct X11Connection *xconn = container_of(
|
||||||
plug, struct X11Connection, plug);
|
plug, struct X11Connection, plug);
|
||||||
|
@ -244,7 +244,7 @@ static void try_send_ssh_to_socket(void *ctx)
|
|||||||
if (sp->rcvd_eof_ssh_to_socket &&
|
if (sp->rcvd_eof_ssh_to_socket &&
|
||||||
!sp->sent_eof_ssh_to_socket) {
|
!sp->sent_eof_ssh_to_socket) {
|
||||||
sp->sent_eof_ssh_to_socket = true;
|
sp->sent_eof_ssh_to_socket = true;
|
||||||
plug_closing(sp->plug, sp->errmsg, 0, 0);
|
plug_closing(sp->plug, sp->errmsg, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -325,7 +325,7 @@ static int sshproxy_get_userpass_input(Seat *seat, prompts_t *p)
|
|||||||
static void sshproxy_connection_fatal_callback(void *vctx)
|
static void sshproxy_connection_fatal_callback(void *vctx)
|
||||||
{
|
{
|
||||||
SshProxy *sp = (SshProxy *)vctx;
|
SshProxy *sp = (SshProxy *)vctx;
|
||||||
plug_closing(sp->plug, sp->errmsg, 0, true);
|
plug_closing(sp->plug, sp->errmsg, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void sshproxy_connection_fatal(Seat *seat, const char *message)
|
static void sshproxy_connection_fatal(Seat *seat, const char *message)
|
||||||
|
@ -158,8 +158,7 @@ static void fdsocket_error_callback(void *vs)
|
|||||||
/*
|
/*
|
||||||
* An error has occurred on this socket. Pass it to the plug.
|
* An error has occurred on this socket. Pass it to the plug.
|
||||||
*/
|
*/
|
||||||
plug_closing(fds->plug, strerror(fds->pending_error),
|
plug_closing(fds->plug, strerror(fds->pending_error), fds->pending_error);
|
||||||
fds->pending_error, 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int fdsocket_try_send(FdSocket *fds)
|
static int fdsocket_try_send(FdSocket *fds)
|
||||||
@ -271,9 +270,9 @@ static void fdsocket_select_result_input(int fd, int event)
|
|||||||
fds->infd = -1;
|
fds->infd = -1;
|
||||||
|
|
||||||
if (retd < 0) {
|
if (retd < 0) {
|
||||||
plug_closing(fds->plug, strerror(errno), errno, 0);
|
plug_closing(fds->plug, strerror(errno), errno);
|
||||||
} else {
|
} else {
|
||||||
plug_closing(fds->plug, NULL, 0, 0);
|
plug_closing(fds->plug, NULL, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1101,7 +1101,7 @@ static void socket_error_callback(void *vs)
|
|||||||
/*
|
/*
|
||||||
* An error has occurred on this socket. Pass it to the plug.
|
* An error has occurred on this socket. Pass it to the plug.
|
||||||
*/
|
*/
|
||||||
plug_closing(s->plug, strerror(s->pending_error), s->pending_error, 0);
|
plug_closing(s->plug, strerror(s->pending_error), s->pending_error);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -1298,7 +1298,7 @@ static void net_select_result(int fd, int event)
|
|||||||
if (ret <= 0) {
|
if (ret <= 0) {
|
||||||
plug_closing(s->plug,
|
plug_closing(s->plug,
|
||||||
ret == 0 ? "Internal networking trouble" :
|
ret == 0 ? "Internal networking trouble" :
|
||||||
strerror(errno), errno, 0);
|
strerror(errno), errno);
|
||||||
} else {
|
} else {
|
||||||
/*
|
/*
|
||||||
* Receiving actual data on a socket means we can
|
* Receiving actual data on a socket means we can
|
||||||
@ -1384,11 +1384,11 @@ static void net_select_result(int fd, int event)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
plug_closing(s->plug, strerror(errno), errno, 0);
|
plug_closing(s->plug, strerror(errno), errno);
|
||||||
} else if (0 == ret) {
|
} else if (0 == ret) {
|
||||||
s->incomingeof = true; /* stop trying to read now */
|
s->incomingeof = true; /* stop trying to read now */
|
||||||
uxsel_tell(s);
|
uxsel_tell(s);
|
||||||
plug_closing(s->plug, NULL, 0, 0);
|
plug_closing(s->plug, NULL, 0);
|
||||||
} else {
|
} else {
|
||||||
/*
|
/*
|
||||||
* Receiving actual data on a socket means we can
|
* Receiving actual data on a socket means we can
|
||||||
@ -1438,7 +1438,7 @@ static void net_select_result(int fd, int event)
|
|||||||
err = try_connect(s);
|
err = try_connect(s);
|
||||||
}
|
}
|
||||||
if (err) {
|
if (err) {
|
||||||
plug_closing(s->plug, strerror(err), err, 0);
|
plug_closing(s->plug, strerror(err), err);
|
||||||
return; /* socket is now presumably defunct */
|
return; /* socket is now presumably defunct */
|
||||||
}
|
}
|
||||||
if (!s->connected)
|
if (!s->connected)
|
||||||
|
@ -249,8 +249,7 @@ static void x11_log(Plug *p, PlugLogType type, SockAddr *addr, int port,
|
|||||||
const char *error_msg, int error_code) {}
|
const char *error_msg, int error_code) {}
|
||||||
static void x11_receive(Plug *plug, int urgent, const char *data, size_t len) {}
|
static void x11_receive(Plug *plug, int urgent, const char *data, size_t len) {}
|
||||||
static void x11_sent(Plug *plug, size_t bufsize) {}
|
static void x11_sent(Plug *plug, size_t bufsize) {}
|
||||||
static void x11_closing(Plug *plug, const char *error_msg, int error_code,
|
static void x11_closing(Plug *plug, const char *error_msg, int error_code)
|
||||||
bool calling_back)
|
|
||||||
{
|
{
|
||||||
time_to_die = true;
|
time_to_die = true;
|
||||||
}
|
}
|
||||||
|
@ -273,8 +273,7 @@ static void server_log(Plug *plug, PlugLogType type, SockAddr *addr, int port,
|
|||||||
log_to_stderr(-1, error_msg);
|
log_to_stderr(-1, error_msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void server_closing(Plug *plug, const char *error_msg, int error_code,
|
static void server_closing(Plug *plug, const char *error_msg, int error_code)
|
||||||
bool calling_back)
|
|
||||||
{
|
{
|
||||||
log_to_stderr(-1, error_msg);
|
log_to_stderr(-1, error_msg);
|
||||||
}
|
}
|
||||||
|
@ -482,8 +482,7 @@ static void server_log(Plug *plug, PlugLogType type, SockAddr *addr, int port,
|
|||||||
log_to_stderr((unsigned)-1, error_msg);
|
log_to_stderr((unsigned)-1, error_msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void server_closing(Plug *plug, const char *error_msg, int error_code,
|
static void server_closing(Plug *plug, const char *error_msg, int error_code)
|
||||||
bool calling_back)
|
|
||||||
{
|
{
|
||||||
log_to_stderr((unsigned)-1, error_msg);
|
log_to_stderr((unsigned)-1, error_msg);
|
||||||
}
|
}
|
||||||
|
@ -53,10 +53,10 @@ static size_t handle_gotdata(
|
|||||||
HandleSocket *hs = (HandleSocket *)handle_get_privdata(h);
|
HandleSocket *hs = (HandleSocket *)handle_get_privdata(h);
|
||||||
|
|
||||||
if (err) {
|
if (err) {
|
||||||
plug_closing(hs->plug, "Read error from handle", 0, 0);
|
plug_closing(hs->plug, "Read error from handle", 0);
|
||||||
return 0;
|
return 0;
|
||||||
} else if (len == 0) {
|
} else if (len == 0) {
|
||||||
plug_closing(hs->plug, NULL, 0, 0);
|
plug_closing(hs->plug, NULL, 0);
|
||||||
return 0;
|
return 0;
|
||||||
} else {
|
} else {
|
||||||
assert(hs->frozen != FROZEN && hs->frozen != THAWING);
|
assert(hs->frozen != FROZEN && hs->frozen != THAWING);
|
||||||
@ -107,7 +107,7 @@ static void handle_sentdata(struct handle *h, size_t new_backlog, int err,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (err) {
|
if (err) {
|
||||||
plug_closing(hs->plug, win_strerror(err), err, 0);
|
plug_closing(hs->plug, win_strerror(err), err);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1353,7 +1353,7 @@ static void socket_error_callback(void *vs)
|
|||||||
* An error has occurred on this socket. Pass it to the plug.
|
* An error has occurred on this socket. Pass it to the plug.
|
||||||
*/
|
*/
|
||||||
plug_closing(s->plug, winsock_error_string(s->pending_error),
|
plug_closing(s->plug, winsock_error_string(s->pending_error),
|
||||||
s->pending_error, 0);
|
s->pending_error);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -1528,7 +1528,7 @@ void select_result(WPARAM wParam, LPARAM lParam)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (err != 0)
|
if (err != 0)
|
||||||
plug_closing(s->plug, winsock_error_string(err), err, 0);
|
plug_closing(s->plug, winsock_error_string(err), err);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1590,9 +1590,9 @@ void select_result(WPARAM wParam, LPARAM lParam)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
plug_closing(s->plug, winsock_error_string(err), err, 0);
|
plug_closing(s->plug, winsock_error_string(err), err);
|
||||||
} else if (0 == ret) {
|
} else if (0 == ret) {
|
||||||
plug_closing(s->plug, NULL, 0, 0);
|
plug_closing(s->plug, NULL, 0);
|
||||||
} else {
|
} else {
|
||||||
plug_receive(s->plug, atmark ? 0 : 1, buf, ret);
|
plug_receive(s->plug, atmark ? 0 : 1, buf, ret);
|
||||||
}
|
}
|
||||||
@ -1608,7 +1608,7 @@ void select_result(WPARAM wParam, LPARAM lParam)
|
|||||||
noise_ultralight(NOISE_SOURCE_IOLEN, ret);
|
noise_ultralight(NOISE_SOURCE_IOLEN, ret);
|
||||||
if (ret <= 0) {
|
if (ret <= 0) {
|
||||||
int err = p_WSAGetLastError();
|
int err = p_WSAGetLastError();
|
||||||
plug_closing(s->plug, winsock_error_string(err), err, 0);
|
plug_closing(s->plug, winsock_error_string(err), err);
|
||||||
} else {
|
} else {
|
||||||
plug_receive(s->plug, 2, buf, ret);
|
plug_receive(s->plug, 2, buf, ret);
|
||||||
}
|
}
|
||||||
@ -1631,12 +1631,12 @@ void select_result(WPARAM wParam, LPARAM lParam)
|
|||||||
err = p_WSAGetLastError();
|
err = p_WSAGetLastError();
|
||||||
if (err == WSAEWOULDBLOCK)
|
if (err == WSAEWOULDBLOCK)
|
||||||
break;
|
break;
|
||||||
plug_closing(s->plug, winsock_error_string(err), err, 0);
|
plug_closing(s->plug, winsock_error_string(err), err);
|
||||||
} else {
|
} else {
|
||||||
if (ret)
|
if (ret)
|
||||||
plug_receive(s->plug, 0, buf, ret);
|
plug_receive(s->plug, 0, buf, ret);
|
||||||
else
|
else
|
||||||
plug_closing(s->plug, NULL, 0, 0);
|
plug_closing(s->plug, NULL, 0);
|
||||||
}
|
}
|
||||||
} while (ret > 0);
|
} while (ret > 0);
|
||||||
return;
|
return;
|
||||||
|
Loading…
Reference in New Issue
Block a user