~mdw
/
sgt
/
putty
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Been meaning to get round to this for a while: use CryptGenRandom to
[sgt/putty]
/
telnet.c
diff --git
a/telnet.c
b/telnet.c
index
dc98a72
..
6a56da7
100644
(file)
--- a/
telnet.c
+++ b/
telnet.c
@@
-4,6
+4,7
@@
#include <stdio.h>
#include <stdlib.h>
#include <stdio.h>
#include <stdlib.h>
+#include <limits.h>
#include "putty.h"
#include "putty.h"
@@
-181,6
+182,7
@@
typedef struct telnet_tag {
/* the above field _must_ be first in the structure */
Socket s;
/* the above field _must_ be first in the structure */
Socket s;
+ int closed_on_socket_error;
void *frontend;
void *ldisc;
void *frontend;
void *ldisc;
@@
-660,6
+662,7
@@
static void telnet_log(Plug plug, int type, SockAddr addr, int port,
msg = dupprintf("Failed to connect to %s: %s", addrbuf, error_msg);
logevent(telnet->frontend, msg);
msg = dupprintf("Failed to connect to %s: %s", addrbuf, error_msg);
logevent(telnet->frontend, msg);
+ sfree(msg);
}
static int telnet_closing(Plug plug, const char *error_msg, int error_code,
}
static int telnet_closing(Plug plug, const char *error_msg, int error_code,
@@
-676,6
+679,8
@@
static int telnet_closing(Plug plug, const char *error_msg, int error_code,
if (telnet->s) {
sk_close(telnet->s);
telnet->s = NULL;
if (telnet->s) {
sk_close(telnet->s);
telnet->s = NULL;
+ if (error_msg)
+ telnet->closed_on_socket_error = TRUE;
notify_remote_exit(telnet->frontend);
}
if (error_msg) {
notify_remote_exit(telnet->frontend);
}
if (error_msg) {
@@
-729,6
+734,7
@@
static const char *telnet_init(void *frontend_handle, void **backend_handle,
telnet->fn = &fn_table;
telnet->conf = conf_copy(conf);
telnet->s = NULL;
telnet->fn = &fn_table;
telnet->conf = conf_copy(conf);
telnet->s = NULL;
+ telnet->closed_on_socket_error = FALSE;
telnet->echoing = TRUE;
telnet->editing = TRUE;
telnet->activated = FALSE;
telnet->echoing = TRUE;
telnet->editing = TRUE;
telnet->activated = FALSE;
@@
-1096,6
+1102,8
@@
static int telnet_exitcode(void *handle)
Telnet telnet = (Telnet) handle;
if (telnet->s != NULL)
return -1; /* still connected */
Telnet telnet = (Telnet) handle;
if (telnet->s != NULL)
return -1; /* still connected */
+ else if (telnet->closed_on_socket_error)
+ return INT_MAX; /* a socket error counts as an unclean exit */
else
/* Telnet doesn't transmit exit codes back to the client */
return 0;
else
/* Telnet doesn't transmit exit codes back to the client */
return 0;