X-Git-Url: https://asedeno.scripts.mit.edu/gitweb/?a=blobdiff_plain;f=raw.c;h=97355e8ad768bd38df89bc653736a386c9143c5b;hb=f004bcca17a789356c32527a396b68b71a773db2;hp=5bf63564be981ab259662576aecfc1781489c0e7;hpb=947962e0b95e10151c186048a8b5cc2fb425838c;p=PuTTY.git diff --git a/raw.c b/raw.c index 5bf63564..97355e8a 100644 --- a/raw.c +++ b/raw.c @@ -4,6 +4,7 @@ #include #include +#include #include "putty.h" @@ -21,6 +22,7 @@ typedef struct raw_backend_data { /* the above field _must_ be first in the structure */ Socket s; + int closed_on_socket_error; int bufsize; void *frontend; int sent_console_eof, sent_socket_eof; @@ -48,6 +50,7 @@ static void raw_log(Plug plug, int type, SockAddr addr, int port, msg = dupprintf("Failed to connect to %s: %s", addrbuf, error_msg); logevent(raw->frontend, msg); + sfree(msg); } static void raw_check_close(Raw raw) @@ -75,6 +78,7 @@ static int raw_closing(Plug plug, const char *error_msg, int error_code, if (raw->s) { sk_close(raw->s); raw->s = NULL; + raw->closed_on_socket_error = TRUE; notify_remote_exit(raw->frontend); } logevent(raw->frontend, error_msg); @@ -139,8 +143,10 @@ static const char *raw_init(void *frontend_handle, void **backend_handle, raw = snew(struct raw_backend_data); raw->fn = &fn_table; raw->s = NULL; + raw->closed_on_socket_error = FALSE; *backend_handle = raw; raw->sent_console_eof = raw->sent_socket_eof = FALSE; + raw->bufsize = 0; raw->frontend = frontend_handle; @@ -180,15 +186,10 @@ static const char *raw_init(void *frontend_handle, void **backend_handle, sfree(*realhost); *realhost = dupstr(loghost); - colon = strrchr(*realhost, ':'); - if (colon) { - /* - * FIXME: if we ever update this aspect of ssh.c for - * IPv6 literal management, this should change in line - * with it. - */ + + colon = host_strrchr(*realhost, ':'); + if (colon) *colon++ = '\0'; - } } return NULL; @@ -306,6 +307,8 @@ static int raw_exitcode(void *handle) Raw raw = (Raw) handle; if (raw->s != NULL) return -1; /* still connected */ + else if (raw->closed_on_socket_error) + return INT_MAX; /* a socket error counts as an unclean exit */ else /* Exit codes are a meaningless concept in the Raw protocol */ return 0;