summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarkus Friedl <markus@cvs.openbsd.org>2003-05-11 20:30:26 +0000
committerMarkus Friedl <markus@cvs.openbsd.org>2003-05-11 20:30:26 +0000
commitf9a1f0ece404c573625c5d9d8e5928b98b594832 (patch)
treee5545ad7ad5e164a51716a8970c1877f0dabbde0
parent28d6cc535f39ad4966114f91b87d8430d8aed77d (diff)
make channel_new() strdup the 'remote_name' (not the caller); ok theo
-rw-r--r--usr.bin/ssh/channels.c29
-rw-r--r--usr.bin/ssh/clientloop.c9
-rw-r--r--usr.bin/ssh/serverloop.c6
-rw-r--r--usr.bin/ssh/session.c4
-rw-r--r--usr.bin/ssh/ssh.c4
5 files changed, 22 insertions, 30 deletions
diff --git a/usr.bin/ssh/channels.c b/usr.bin/ssh/channels.c
index 64c5d8d82ff..58c8b4b4107 100644
--- a/usr.bin/ssh/channels.c
+++ b/usr.bin/ssh/channels.c
@@ -39,7 +39,7 @@
*/
#include "includes.h"
-RCSID("$OpenBSD: channels.c,v 1.189 2003/04/14 14:17:50 markus Exp $");
+RCSID("$OpenBSD: channels.c,v 1.190 2003/05/11 20:30:24 markus Exp $");
#include "ssh.h"
#include "ssh1.h"
@@ -255,7 +255,7 @@ channel_new(char *ctype, int type, int rfd, int wfd, int efd,
c->local_consumed = 0;
c->local_maxpacket = maxpack;
c->remote_id = -1;
- c->remote_name = remote_name;
+ c->remote_name = xstrdup(remote_name);
c->remote_window = 0;
c->remote_maxpacket = 0;
c->force_drain = 0;
@@ -1012,8 +1012,7 @@ channel_post_x11_listener(Channel *c, fd_set * readset, fd_set * writeset)
nc = channel_new("accepted x11 socket",
SSH_CHANNEL_OPENING, newsock, newsock, -1,
- c->local_window_max, c->local_maxpacket,
- 0, xstrdup(buf), 1);
+ c->local_window_max, c->local_maxpacket, 0, buf, 1);
if (compat20) {
packet_start(SSH2_MSG_CHANNEL_OPEN);
packet_put_cstring("x11");
@@ -1128,10 +1127,8 @@ channel_post_port_listener(Channel *c, fd_set * readset, fd_set * writeset)
return;
}
set_nodelay(newsock);
- nc = channel_new(rtype,
- nextstate, newsock, newsock, -1,
- c->local_window_max, c->local_maxpacket,
- 0, xstrdup(rtype), 1);
+ nc = channel_new(rtype, nextstate, newsock, newsock, -1,
+ c->local_window_max, c->local_maxpacket, 0, rtype, 1);
nc->listening_port = c->listening_port;
nc->host_port = c->host_port;
strlcpy(nc->path, c->path, sizeof(nc->path));
@@ -1157,7 +1154,6 @@ static void
channel_post_auth_listener(Channel *c, fd_set * readset, fd_set * writeset)
{
Channel *nc;
- char *name;
int newsock;
struct sockaddr addr;
socklen_t addrlen;
@@ -1169,11 +1165,10 @@ channel_post_auth_listener(Channel *c, fd_set * readset, fd_set * writeset)
error("accept from auth socket: %.100s", strerror(errno));
return;
}
- name = xstrdup("accepted auth socket");
nc = channel_new("accepted auth socket",
SSH_CHANNEL_OPENING, newsock, newsock, -1,
c->local_window_max, c->local_maxpacket,
- 0, name, 1);
+ 0, "accepted auth socket", 1);
if (compat20) {
packet_start(SSH2_MSG_CHANNEL_OPEN);
packet_put_cstring("auth-agent@openssh.com");
@@ -1990,8 +1985,8 @@ channel_input_port_open(int type, u_int32_t seq, void *ctxt)
originator_string, 1);
c->remote_id = remote_id;
}
+ xfree(originator_string);
if (c == NULL) {
- xfree(originator_string);
packet_start(SSH_MSG_CHANNEL_OPEN_FAILURE);
packet_put_int(remote_id);
packet_send();
@@ -2084,7 +2079,7 @@ channel_setup_fwd_listener(int type, const char *listen_addr, u_short listen_por
/* Allocate a channel number for the socket. */
c = channel_new("port listener", type, sock, sock, -1,
CHAN_TCP_WINDOW_DEFAULT, CHAN_TCP_PACKET_DEFAULT,
- 0, xstrdup("port listener"), 1);
+ 0, "port listener", 1);
strlcpy(c->path, host, sizeof(c->path));
c->host_port = port_to_connect;
c->listening_port = listen_port;
@@ -2416,7 +2411,7 @@ x11_create_display_inet(int x11_display_offset, int x11_use_localhost,
nc = channel_new("x11 listener",
SSH_CHANNEL_X11_LISTENER, sock, sock, -1,
CHAN_X11_WINDOW_DEFAULT, CHAN_X11_PACKET_DEFAULT,
- 0, xstrdup("X11 inet listener"), 1);
+ 0, "X11 inet listener", 1);
nc->single_connection = single_connection;
}
@@ -2573,11 +2568,11 @@ x11_input_open(int type, u_int32_t seq, void *ctxt)
c->remote_id = remote_id;
c->force_drain = 1;
}
+ xfree(remote_host);
if (c == NULL) {
/* Send refusal to the remote host. */
packet_start(SSH_MSG_CHANNEL_OPEN_FAILURE);
packet_put_int(remote_id);
- xfree(remote_host);
} else {
/* Send a confirmation to the remote host. */
packet_start(SSH_MSG_CHANNEL_OPEN_CONFIRMATION);
@@ -2699,7 +2694,6 @@ auth_input_open_request(int type, u_int32_t seq, void *ctxt)
{
Channel *c = NULL;
int remote_id, sock;
- char *name;
/* Read the remote channel number from the message. */
remote_id = packet_get_int();
@@ -2718,9 +2712,8 @@ auth_input_open_request(int type, u_int32_t seq, void *ctxt)
* agent.
*/
if (sock >= 0) {
- name = xstrdup("authentication agent connection");
c = channel_new("", SSH_CHANNEL_OPEN, sock, sock,
- -1, 0, 0, 0, name, 1);
+ -1, 0, 0, 0, "authentication agent connection", 1);
c->remote_id = remote_id;
c->force_drain = 1;
}
diff --git a/usr.bin/ssh/clientloop.c b/usr.bin/ssh/clientloop.c
index e4ef7163234..e5270aa57f1 100644
--- a/usr.bin/ssh/clientloop.c
+++ b/usr.bin/ssh/clientloop.c
@@ -59,7 +59,7 @@
*/
#include "includes.h"
-RCSID("$OpenBSD: clientloop.c,v 1.109 2003/04/08 20:21:28 itojun Exp $");
+RCSID("$OpenBSD: clientloop.c,v 1.110 2003/05/11 20:30:24 markus Exp $");
#include "ssh.h"
#include "ssh1.h"
@@ -1145,7 +1145,7 @@ client_request_forwarded_tcpip(const char *request_type, int rchan)
c = channel_new("forwarded-tcpip",
SSH_CHANNEL_CONNECTING, sock, sock, -1,
CHAN_TCP_WINDOW_DEFAULT, CHAN_TCP_WINDOW_DEFAULT, 0,
- xstrdup(originator_address), 1);
+ originator_address, 1);
xfree(originator_address);
xfree(listen_address);
return c;
@@ -1181,8 +1181,7 @@ client_request_x11(const char *request_type, int rchan)
return NULL;
c = channel_new("x11",
SSH_CHANNEL_X11_OPEN, sock, sock, -1,
- CHAN_TCP_WINDOW_DEFAULT, CHAN_X11_PACKET_DEFAULT, 0,
- xstrdup("x11"), 1);
+ CHAN_TCP_WINDOW_DEFAULT, CHAN_X11_PACKET_DEFAULT, 0, "x11", 1);
c->force_drain = 1;
return c;
}
@@ -1204,7 +1203,7 @@ client_request_agent(const char *request_type, int rchan)
c = channel_new("authentication agent connection",
SSH_CHANNEL_OPEN, sock, sock, -1,
CHAN_X11_WINDOW_DEFAULT, CHAN_TCP_WINDOW_DEFAULT, 0,
- xstrdup("authentication agent connection"), 1);
+ "authentication agent connection", 1);
c->force_drain = 1;
return c;
}
diff --git a/usr.bin/ssh/serverloop.c b/usr.bin/ssh/serverloop.c
index 0e41a7580f3..9c1fbb1baed 100644
--- a/usr.bin/ssh/serverloop.c
+++ b/usr.bin/ssh/serverloop.c
@@ -35,7 +35,7 @@
*/
#include "includes.h"
-RCSID("$OpenBSD: serverloop.c,v 1.107 2003/04/02 09:48:07 markus Exp $");
+RCSID("$OpenBSD: serverloop.c,v 1.108 2003/05/11 20:30:24 markus Exp $");
#include "xmalloc.h"
#include "packet.h"
@@ -878,7 +878,7 @@ server_request_direct_tcpip(char *ctype)
return NULL;
c = channel_new(ctype, SSH_CHANNEL_CONNECTING,
sock, sock, -1, CHAN_TCP_WINDOW_DEFAULT,
- CHAN_TCP_PACKET_DEFAULT, 0, xstrdup("direct-tcpip"), 1);
+ CHAN_TCP_PACKET_DEFAULT, 0, "direct-tcpip", 1);
return c;
}
@@ -897,7 +897,7 @@ server_request_session(char *ctype)
*/
c = channel_new(ctype, SSH_CHANNEL_LARVAL,
-1, -1, -1, /*window size*/0, CHAN_SES_PACKET_DEFAULT,
- 0, xstrdup("server-session"), 1);
+ 0, "server-session", 1);
if (session_open(xxx_authctxt, c->self) != 1) {
debug("session open failed, free channel %d", c->self);
channel_free(c);
diff --git a/usr.bin/ssh/session.c b/usr.bin/ssh/session.c
index 5fd2eed7871..ae671ef2331 100644
--- a/usr.bin/ssh/session.c
+++ b/usr.bin/ssh/session.c
@@ -33,7 +33,7 @@
*/
#include "includes.h"
-RCSID("$OpenBSD: session.c,v 1.155 2003/04/08 20:21:29 itojun Exp $");
+RCSID("$OpenBSD: session.c,v 1.156 2003/05/11 20:30:25 markus Exp $");
#include "ssh.h"
#include "ssh1.h"
@@ -179,7 +179,7 @@ auth_input_request_forwarding(struct passwd * pw)
nc = channel_new("auth socket",
SSH_CHANNEL_AUTH_SOCKET, sock, sock, -1,
CHAN_X11_WINDOW_DEFAULT, CHAN_X11_PACKET_DEFAULT,
- 0, xstrdup("auth socket"), 1);
+ 0, "auth socket", 1);
strlcpy(nc->path, auth_sock_name, sizeof(nc->path));
return 1;
}
diff --git a/usr.bin/ssh/ssh.c b/usr.bin/ssh/ssh.c
index 2bf38bf0368..940d08d8d65 100644
--- a/usr.bin/ssh/ssh.c
+++ b/usr.bin/ssh/ssh.c
@@ -40,7 +40,7 @@
*/
#include "includes.h"
-RCSID("$OpenBSD: ssh.c,v 1.191 2003/04/08 20:21:29 itojun Exp $");
+RCSID("$OpenBSD: ssh.c,v 1.192 2003/05/11 20:30:25 markus Exp $");
#include <openssl/evp.h>
#include <openssl/err.h>
@@ -1108,7 +1108,7 @@ ssh_session2_open(void)
c = channel_new(
"session", SSH_CHANNEL_OPENING, in, out, err,
window, packetmax, CHAN_EXTENDED_WRITE,
- xstrdup("client-session"), /*nonblock*/0);
+ "client-session", /*nonblock*/0);
debug3("ssh_session2_open: channel_new: %d", c->self);