#include <stdio.h>
#include <stdlib.h>
+#include <limits.h>
#include "putty.h"
/* the above field _must_ be first in the structure */
Socket s;
+ int closed_on_socket_error;
void *frontend;
void *ldisc;
else if (o->option == TELOPT_SGA && o->send == DO)
telnet->editing = !enabled;
if (telnet->ldisc) /* cause ldisc to notice the change */
- ldisc_send(telnet->ldisc, NULL, 0, 0);
+ ldisc_echoedit_update(telnet->ldisc);
/* Ensure we get the minimum options */
if (!telnet->activated) {
logevent(telnet->frontend, logbuf);
sfree(logbuf);
if (telnet->sb_opt == TELOPT_OLD_ENVIRON) {
- if (conf_get_str(telnet->conf, CONF_rfc_environ)) {
+ if (conf_get_int(telnet->conf, CONF_rfc_environ)) {
value = RFC_VALUE;
var = RFC_VAR;
} else {
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,
{
Telnet telnet = (Telnet) plug;
+ /*
+ * We don't implement independent EOF in each direction for Telnet
+ * connections; as soon as we get word that the remote side has
+ * sent us EOF, we wind up the whole connection.
+ */
+
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) {
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;
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;
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;