Upgrade to 6.3p1.
Approved by: re (gjb)
This commit is contained in:
+49
-42
@@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: clientloop.c,v 1.248 2013/01/02 00:32:07 djm Exp $ */
|
||||
/* $OpenBSD: clientloop.c,v 1.253 2013/06/07 15:37:52 dtucker Exp $ */
|
||||
/* $FreeBSD$ */
|
||||
/*
|
||||
* Author: Tatu Ylonen <ylo@cs.hut.fi>
|
||||
@@ -274,7 +274,7 @@ set_control_persist_exit_time(void)
|
||||
control_persist_exit_time = 0;
|
||||
} else if (control_persist_exit_time <= 0) {
|
||||
/* a client connection has recently closed */
|
||||
control_persist_exit_time = time(NULL) +
|
||||
control_persist_exit_time = monotime() +
|
||||
(time_t)options.control_persist_timeout;
|
||||
debug2("%s: schedule exit in %d seconds", __func__,
|
||||
options.control_persist_timeout);
|
||||
@@ -357,7 +357,7 @@ client_x11_get_proto(const char *display, const char *xauth_path,
|
||||
if (system(cmd) == 0)
|
||||
generated = 1;
|
||||
if (x11_refuse_time == 0) {
|
||||
now = time(NULL) + 1;
|
||||
now = monotime() + 1;
|
||||
if (UINT_MAX - timeout < now)
|
||||
x11_refuse_time = UINT_MAX;
|
||||
else
|
||||
@@ -394,10 +394,8 @@ client_x11_get_proto(const char *display, const char *xauth_path,
|
||||
unlink(xauthfile);
|
||||
rmdir(xauthdir);
|
||||
}
|
||||
if (xauthdir)
|
||||
xfree(xauthdir);
|
||||
if (xauthfile)
|
||||
xfree(xauthfile);
|
||||
free(xauthdir);
|
||||
free(xauthfile);
|
||||
|
||||
/*
|
||||
* If we didn't get authentication data, just make up some
|
||||
@@ -553,7 +551,7 @@ client_global_request_reply(int type, u_int32_t seq, void *ctxt)
|
||||
if (--gc->ref_count <= 0) {
|
||||
TAILQ_REMOVE(&global_confirms, gc, entry);
|
||||
bzero(gc, sizeof(*gc));
|
||||
xfree(gc);
|
||||
free(gc);
|
||||
}
|
||||
|
||||
packet_set_alive_timeouts(0);
|
||||
@@ -584,7 +582,7 @@ client_wait_until_can_do_something(fd_set **readsetp, fd_set **writesetp,
|
||||
{
|
||||
struct timeval tv, *tvp;
|
||||
int timeout_secs;
|
||||
time_t minwait_secs = 0;
|
||||
time_t minwait_secs = 0, server_alive_time = 0, now = monotime();
|
||||
int ret;
|
||||
|
||||
/* Add any selections by the channel mechanism. */
|
||||
@@ -633,12 +631,16 @@ client_wait_until_can_do_something(fd_set **readsetp, fd_set **writesetp,
|
||||
*/
|
||||
|
||||
timeout_secs = INT_MAX; /* we use INT_MAX to mean no timeout */
|
||||
if (options.server_alive_interval > 0 && compat20)
|
||||
if (options.server_alive_interval > 0 && compat20) {
|
||||
timeout_secs = options.server_alive_interval;
|
||||
server_alive_time = now + options.server_alive_interval;
|
||||
}
|
||||
if (options.rekey_interval > 0 && compat20 && !rekeying)
|
||||
timeout_secs = MIN(timeout_secs, packet_get_rekey_timeout());
|
||||
set_control_persist_exit_time();
|
||||
if (control_persist_exit_time > 0) {
|
||||
timeout_secs = MIN(timeout_secs,
|
||||
control_persist_exit_time - time(NULL));
|
||||
control_persist_exit_time - now);
|
||||
if (timeout_secs < 0)
|
||||
timeout_secs = 0;
|
||||
}
|
||||
@@ -670,8 +672,15 @@ client_wait_until_can_do_something(fd_set **readsetp, fd_set **writesetp,
|
||||
snprintf(buf, sizeof buf, "select: %s\r\n", strerror(errno));
|
||||
buffer_append(&stderr_buffer, buf, strlen(buf));
|
||||
quit_pending = 1;
|
||||
} else if (ret == 0)
|
||||
server_alive_check();
|
||||
} else if (ret == 0) {
|
||||
/*
|
||||
* Timeout. Could have been either keepalive or rekeying.
|
||||
* Keepalive we check here, rekeying is checked in clientloop.
|
||||
*/
|
||||
if (server_alive_time != 0 && server_alive_time <= monotime())
|
||||
server_alive_check();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -816,13 +825,13 @@ client_status_confirm(int type, Channel *c, void *ctx)
|
||||
chan_write_failed(c);
|
||||
}
|
||||
}
|
||||
xfree(cr);
|
||||
free(cr);
|
||||
}
|
||||
|
||||
static void
|
||||
client_abandon_status_confirm(Channel *c, void *ctx)
|
||||
{
|
||||
xfree(ctx);
|
||||
free(ctx);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -989,12 +998,9 @@ process_cmdline(void)
|
||||
out:
|
||||
signal(SIGINT, handler);
|
||||
enter_raw_mode(options.request_tty == REQUEST_TTY_FORCE);
|
||||
if (cmd)
|
||||
xfree(cmd);
|
||||
if (fwd.listen_host != NULL)
|
||||
xfree(fwd.listen_host);
|
||||
if (fwd.connect_host != NULL)
|
||||
xfree(fwd.connect_host);
|
||||
free(cmd);
|
||||
free(fwd.listen_host);
|
||||
free(fwd.connect_host);
|
||||
}
|
||||
|
||||
/* reasons to suppress output of an escape command in help output */
|
||||
@@ -1104,8 +1110,11 @@ process_escapes(Channel *c, Buffer *bin, Buffer *bout, Buffer *berr,
|
||||
if (c && c->ctl_chan != -1) {
|
||||
chan_read_failed(c);
|
||||
chan_write_failed(c);
|
||||
mux_master_session_cleanup_cb(c->self,
|
||||
NULL);
|
||||
if (c->detach_user)
|
||||
c->detach_user(c->self, NULL);
|
||||
c->type = SSH_CHANNEL_ABANDONED;
|
||||
buffer_clear(&c->input);
|
||||
chan_ibuf_empty(c);
|
||||
return 0;
|
||||
} else
|
||||
quit_pending = 1;
|
||||
@@ -1251,7 +1260,7 @@ process_escapes(Channel *c, Buffer *bin, Buffer *bout, Buffer *berr,
|
||||
buffer_append(berr, string, strlen(string));
|
||||
s = channel_open_message();
|
||||
buffer_append(berr, s, strlen(s));
|
||||
xfree(s);
|
||||
free(s);
|
||||
continue;
|
||||
|
||||
case 'C':
|
||||
@@ -1440,7 +1449,7 @@ client_new_escape_filter_ctx(int escape_char)
|
||||
void
|
||||
client_filter_cleanup(int cid, void *ctx)
|
||||
{
|
||||
xfree(ctx);
|
||||
free(ctx);
|
||||
}
|
||||
|
||||
int
|
||||
@@ -1645,16 +1654,14 @@ client_loop(int have_pty, int escape_char_arg, int ssh2_chan_id)
|
||||
* connections, then quit.
|
||||
*/
|
||||
if (control_persist_exit_time > 0) {
|
||||
if (time(NULL) >= control_persist_exit_time) {
|
||||
if (monotime() >= control_persist_exit_time) {
|
||||
debug("ControlPersist timeout expired");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (readset)
|
||||
xfree(readset);
|
||||
if (writeset)
|
||||
xfree(writeset);
|
||||
free(readset);
|
||||
free(writeset);
|
||||
|
||||
/* Terminate the session. */
|
||||
|
||||
@@ -1756,7 +1763,7 @@ client_input_stdout_data(int type, u_int32_t seq, void *ctxt)
|
||||
packet_check_eom();
|
||||
buffer_append(&stdout_buffer, data, data_len);
|
||||
memset(data, 0, data_len);
|
||||
xfree(data);
|
||||
free(data);
|
||||
}
|
||||
static void
|
||||
client_input_stderr_data(int type, u_int32_t seq, void *ctxt)
|
||||
@@ -1766,7 +1773,7 @@ client_input_stderr_data(int type, u_int32_t seq, void *ctxt)
|
||||
packet_check_eom();
|
||||
buffer_append(&stderr_buffer, data, data_len);
|
||||
memset(data, 0, data_len);
|
||||
xfree(data);
|
||||
free(data);
|
||||
}
|
||||
static void
|
||||
client_input_exit_status(int type, u_int32_t seq, void *ctxt)
|
||||
@@ -1846,8 +1853,8 @@ client_request_forwarded_tcpip(const char *request_type, int rchan)
|
||||
c = channel_connect_by_listen_address(listen_port,
|
||||
"forwarded-tcpip", originator_address);
|
||||
|
||||
xfree(originator_address);
|
||||
xfree(listen_address);
|
||||
free(originator_address);
|
||||
free(listen_address);
|
||||
return c;
|
||||
}
|
||||
|
||||
@@ -1865,7 +1872,7 @@ client_request_x11(const char *request_type, int rchan)
|
||||
"malicious server.");
|
||||
return NULL;
|
||||
}
|
||||
if (x11_refuse_time != 0 && time(NULL) >= x11_refuse_time) {
|
||||
if (x11_refuse_time != 0 && monotime() >= x11_refuse_time) {
|
||||
verbose("Rejected X11 connection after ForwardX11Timeout "
|
||||
"expired");
|
||||
return NULL;
|
||||
@@ -1881,7 +1888,7 @@ client_request_x11(const char *request_type, int rchan)
|
||||
/* XXX check permission */
|
||||
debug("client_request_x11: request from %s %d", originator,
|
||||
originator_port);
|
||||
xfree(originator);
|
||||
free(originator);
|
||||
sock = x11_connect_display();
|
||||
if (sock < 0)
|
||||
return NULL;
|
||||
@@ -2025,7 +2032,7 @@ client_input_channel_open(int type, u_int32_t seq, void *ctxt)
|
||||
}
|
||||
packet_send();
|
||||
}
|
||||
xfree(ctype);
|
||||
free(ctype);
|
||||
}
|
||||
static void
|
||||
client_input_channel_req(int type, u_int32_t seq, void *ctxt)
|
||||
@@ -2071,7 +2078,7 @@ client_input_channel_req(int type, u_int32_t seq, void *ctxt)
|
||||
packet_put_int(c->remote_id);
|
||||
packet_send();
|
||||
}
|
||||
xfree(rtype);
|
||||
free(rtype);
|
||||
}
|
||||
static void
|
||||
client_input_global_request(int type, u_int32_t seq, void *ctxt)
|
||||
@@ -2090,7 +2097,7 @@ client_input_global_request(int type, u_int32_t seq, void *ctxt)
|
||||
packet_send();
|
||||
packet_write_wait();
|
||||
}
|
||||
xfree(rtype);
|
||||
free(rtype);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -2140,7 +2147,7 @@ client_session2_setup(int id, int want_tty, int want_subsystem,
|
||||
/* Split */
|
||||
name = xstrdup(env[i]);
|
||||
if ((val = strchr(name, '=')) == NULL) {
|
||||
xfree(name);
|
||||
free(name);
|
||||
continue;
|
||||
}
|
||||
*val++ = '\0';
|
||||
@@ -2154,7 +2161,7 @@ client_session2_setup(int id, int want_tty, int want_subsystem,
|
||||
}
|
||||
if (!matched) {
|
||||
debug3("Ignored env %s", name);
|
||||
xfree(name);
|
||||
free(name);
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -2163,7 +2170,7 @@ client_session2_setup(int id, int want_tty, int want_subsystem,
|
||||
packet_put_cstring(name);
|
||||
packet_put_cstring(val);
|
||||
packet_send();
|
||||
xfree(name);
|
||||
free(name);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user