summaryrefslogtreecommitdiff
path: root/session.c
diff options
context:
space:
mode:
authorDarren Tucker <dtucker@zip.com.au>2013-06-02 07:31:17 +1000
committerDarren Tucker <dtucker@zip.com.au>2013-06-02 07:31:17 +1000
commita627d42e51ffa71e014d7b2d2c07118122fd3ec3 (patch)
tree7bda769de81f509e28d800916fa20abd37906d79 /session.c
parentc7aad0058c957afeb26a3f703e8cb0eddeb62365 (diff)
- djm@cvs.openbsd.org 2013/05/17 00:13:13
[xmalloc.h cipher.c sftp-glob.c ssh-keyscan.c ssh.c sftp-common.c ssh-ecdsa.c auth2-chall.c compat.c readconf.c kexgexs.c monitor.c gss-genr.c cipher-3des1.c kex.c monitor_wrap.c ssh-pkcs11-client.c auth-options.c rsa.c auth2-pubkey.c sftp.c hostfile.c auth2.c servconf.c auth.c authfile.c xmalloc.c uuencode.c sftp-client.c auth2-gss.c sftp-server.c bufaux.c mac.c session.c jpake.c kexgexc.c sshconnect.c auth-chall.c auth2-passwd.c sshconnect1.c buffer.c kexecdhs.c kexdhs.c ssh-rsa.c auth1.c ssh-pkcs11.c auth2-kbdint.c kexdhc.c sshd.c umac.c ssh-dss.c auth2-jpake.c bufbn.c clientloop.c monitor_mm.c scp.c roaming_client.c serverloop.c key.c auth-rsa.c ssh-pkcs11-helper.c ssh-keysign.c ssh-keygen.c match.c channels.c sshconnect2.c addrmatch.c mux.c canohost.c kexecdhc.c schnorr.c ssh-add.c misc.c auth2-hostbased.c ssh-agent.c bufec.c groupaccess.c dns.c packet.c readpass.c authfd.c moduli.c] bye, bye xfree(); ok markus@
Diffstat (limited to 'session.c')
-rw-r--r--session.c92
1 files changed, 38 insertions, 54 deletions
diff --git a/session.c b/session.c
index 4c4461ded..f47cc1788 100644
--- a/session.c
+++ b/session.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: session.c,v 1.264 2013/04/19 01:03:01 djm Exp $ */ 1/* $OpenBSD: session.c,v 1.265 2013/05/17 00:13:14 djm Exp $ */
2/* 2/*
3 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland 3 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
4 * All rights reserved 4 * All rights reserved
@@ -199,7 +199,7 @@ auth_input_request_forwarding(struct passwd * pw)
199 packet_send_debug("Agent forwarding disabled: " 199 packet_send_debug("Agent forwarding disabled: "
200 "mkdtemp() failed: %.100s", strerror(errno)); 200 "mkdtemp() failed: %.100s", strerror(errno));
201 restore_uid(); 201 restore_uid();
202 xfree(auth_sock_dir); 202 free(auth_sock_dir);
203 auth_sock_dir = NULL; 203 auth_sock_dir = NULL;
204 goto authsock_err; 204 goto authsock_err;
205 } 205 }
@@ -244,11 +244,10 @@ auth_input_request_forwarding(struct passwd * pw)
244 return 1; 244 return 1;
245 245
246 authsock_err: 246 authsock_err:
247 if (auth_sock_name != NULL) 247 free(auth_sock_name);
248 xfree(auth_sock_name);
249 if (auth_sock_dir != NULL) { 248 if (auth_sock_dir != NULL) {
250 rmdir(auth_sock_dir); 249 rmdir(auth_sock_dir);
251 xfree(auth_sock_dir); 250 free(auth_sock_dir);
252 } 251 }
253 if (sock != -1) 252 if (sock != -1)
254 close(sock); 253 close(sock);
@@ -364,8 +363,8 @@ do_authenticated1(Authctxt *authctxt)
364 packet_check_eom(); 363 packet_check_eom();
365 success = session_setup_x11fwd(s); 364 success = session_setup_x11fwd(s);
366 if (!success) { 365 if (!success) {
367 xfree(s->auth_proto); 366 free(s->auth_proto);
368 xfree(s->auth_data); 367 free(s->auth_data);
369 s->auth_proto = NULL; 368 s->auth_proto = NULL;
370 s->auth_data = NULL; 369 s->auth_data = NULL;
371 } 370 }
@@ -412,7 +411,7 @@ do_authenticated1(Authctxt *authctxt)
412 if (do_exec(s, command) != 0) 411 if (do_exec(s, command) != 0)
413 packet_disconnect( 412 packet_disconnect(
414 "command execution failed"); 413 "command execution failed");
415 xfree(command); 414 free(command);
416 } else { 415 } else {
417 if (do_exec(s, NULL) != 0) 416 if (do_exec(s, NULL) != 0)
418 packet_disconnect( 417 packet_disconnect(
@@ -977,7 +976,7 @@ child_set_env(char ***envp, u_int *envsizep, const char *name,
977 break; 976 break;
978 if (env[i]) { 977 if (env[i]) {
979 /* Reuse the slot. */ 978 /* Reuse the slot. */
980 xfree(env[i]); 979 free(env[i]);
981 } else { 980 } else {
982 /* New variable. Expand if necessary. */ 981 /* New variable. Expand if necessary. */
983 envsize = *envsizep; 982 envsize = *envsizep;
@@ -1219,8 +1218,8 @@ do_setup_env(Session *s, const char *shell)
1219 child_set_env(&env, &envsize, str, str + i + 1); 1218 child_set_env(&env, &envsize, str, str + i + 1);
1220 } 1219 }
1221 custom_environment = ce->next; 1220 custom_environment = ce->next;
1222 xfree(ce->s); 1221 free(ce->s);
1223 xfree(ce); 1222 free(ce);
1224 } 1223 }
1225 } 1224 }
1226 1225
@@ -1232,7 +1231,7 @@ do_setup_env(Session *s, const char *shell)
1232 laddr = get_local_ipaddr(packet_get_connection_in()); 1231 laddr = get_local_ipaddr(packet_get_connection_in());
1233 snprintf(buf, sizeof buf, "%.50s %d %.50s %d", 1232 snprintf(buf, sizeof buf, "%.50s %d %.50s %d",
1234 get_remote_ipaddr(), get_remote_port(), laddr, get_local_port()); 1233 get_remote_ipaddr(), get_remote_port(), laddr, get_local_port());
1235 xfree(laddr); 1234 free(laddr);
1236 child_set_env(&env, &envsize, "SSH_CONNECTION", buf); 1235 child_set_env(&env, &envsize, "SSH_CONNECTION", buf);
1237 1236
1238 if (s->ttyfd != -1) 1237 if (s->ttyfd != -1)
@@ -1403,7 +1402,7 @@ do_nologin(struct passwd *pw)
1403#endif 1402#endif
1404 if (stat(nl, &sb) == -1) { 1403 if (stat(nl, &sb) == -1) {
1405 if (nl != def_nl) 1404 if (nl != def_nl)
1406 xfree(nl); 1405 free(nl);
1407 return; 1406 return;
1408 } 1407 }
1409 1408
@@ -2054,7 +2053,7 @@ session_pty_req(Session *s)
2054 s->ypixel = packet_get_int(); 2053 s->ypixel = packet_get_int();
2055 2054
2056 if (strcmp(s->term, "") == 0) { 2055 if (strcmp(s->term, "") == 0) {
2057 xfree(s->term); 2056 free(s->term);
2058 s->term = NULL; 2057 s->term = NULL;
2059 } 2058 }
2060 2059
@@ -2062,8 +2061,7 @@ session_pty_req(Session *s)
2062 debug("Allocating pty."); 2061 debug("Allocating pty.");
2063 if (!PRIVSEP(pty_allocate(&s->ptyfd, &s->ttyfd, s->tty, 2062 if (!PRIVSEP(pty_allocate(&s->ptyfd, &s->ttyfd, s->tty,
2064 sizeof(s->tty)))) { 2063 sizeof(s->tty)))) {
2065 if (s->term) 2064 free(s->term);
2066 xfree(s->term);
2067 s->term = NULL; 2065 s->term = NULL;
2068 s->ptyfd = -1; 2066 s->ptyfd = -1;
2069 s->ttyfd = -1; 2067 s->ttyfd = -1;
@@ -2124,7 +2122,7 @@ session_subsystem_req(Session *s)
2124 logit("subsystem request for %.100s failed, subsystem not found", 2122 logit("subsystem request for %.100s failed, subsystem not found",
2125 subsys); 2123 subsys);
2126 2124
2127 xfree(subsys); 2125 free(subsys);
2128 return success; 2126 return success;
2129} 2127}
2130 2128
@@ -2146,8 +2144,8 @@ session_x11_req(Session *s)
2146 2144
2147 success = session_setup_x11fwd(s); 2145 success = session_setup_x11fwd(s);
2148 if (!success) { 2146 if (!success) {
2149 xfree(s->auth_proto); 2147 free(s->auth_proto);
2150 xfree(s->auth_data); 2148 free(s->auth_data);
2151 s->auth_proto = NULL; 2149 s->auth_proto = NULL;
2152 s->auth_data = NULL; 2150 s->auth_data = NULL;
2153 } 2151 }
@@ -2169,7 +2167,7 @@ session_exec_req(Session *s)
2169 char *command = packet_get_string(&len); 2167 char *command = packet_get_string(&len);
2170 packet_check_eom(); 2168 packet_check_eom();
2171 success = do_exec(s, command) == 0; 2169 success = do_exec(s, command) == 0;
2172 xfree(command); 2170 free(command);
2173 return success; 2171 return success;
2174} 2172}
2175 2173
@@ -2215,8 +2213,8 @@ session_env_req(Session *s)
2215 debug2("Ignoring env request %s: disallowed name", name); 2213 debug2("Ignoring env request %s: disallowed name", name);
2216 2214
2217 fail: 2215 fail:
2218 xfree(name); 2216 free(name);
2219 xfree(val); 2217 free(val);
2220 return (0); 2218 return (0);
2221} 2219}
2222 2220
@@ -2398,24 +2396,16 @@ session_close_single_x11(int id, void *arg)
2398 if (s->x11_chanids[i] != id) 2396 if (s->x11_chanids[i] != id)
2399 session_close_x11(s->x11_chanids[i]); 2397 session_close_x11(s->x11_chanids[i]);
2400 } 2398 }
2401 xfree(s->x11_chanids); 2399 free(s->x11_chanids);
2402 s->x11_chanids = NULL; 2400 s->x11_chanids = NULL;
2403 if (s->display) { 2401 free(s->display);
2404 xfree(s->display); 2402 s->display = NULL;
2405 s->display = NULL; 2403 free(s->auth_proto);
2406 } 2404 s->auth_proto = NULL;
2407 if (s->auth_proto) { 2405 free(s->auth_data);
2408 xfree(s->auth_proto); 2406 s->auth_data = NULL;
2409 s->auth_proto = NULL; 2407 free(s->auth_display);
2410 } 2408 s->auth_display = NULL;
2411 if (s->auth_data) {
2412 xfree(s->auth_data);
2413 s->auth_data = NULL;
2414 }
2415 if (s->auth_display) {
2416 xfree(s->auth_display);
2417 s->auth_display = NULL;
2418 }
2419} 2409}
2420 2410
2421static void 2411static void
@@ -2477,24 +2467,18 @@ session_close(Session *s)
2477 debug("session_close: session %d pid %ld", s->self, (long)s->pid); 2467 debug("session_close: session %d pid %ld", s->self, (long)s->pid);
2478 if (s->ttyfd != -1) 2468 if (s->ttyfd != -1)
2479 session_pty_cleanup(s); 2469 session_pty_cleanup(s);
2480 if (s->term) 2470 free(s->term);
2481 xfree(s->term); 2471 free(s->display);
2482 if (s->display) 2472 free(s->x11_chanids);
2483 xfree(s->display); 2473 free(s->auth_display);
2484 if (s->x11_chanids) 2474 free(s->auth_data);
2485 xfree(s->x11_chanids); 2475 free(s->auth_proto);
2486 if (s->auth_display)
2487 xfree(s->auth_display);
2488 if (s->auth_data)
2489 xfree(s->auth_data);
2490 if (s->auth_proto)
2491 xfree(s->auth_proto);
2492 if (s->env != NULL) { 2476 if (s->env != NULL) {
2493 for (i = 0; i < s->num_env; i++) { 2477 for (i = 0; i < s->num_env; i++) {
2494 xfree(s->env[i].name); 2478 free(s->env[i].name);
2495 xfree(s->env[i].val); 2479 free(s->env[i].val);
2496 } 2480 }
2497 xfree(s->env); 2481 free(s->env);
2498 } 2482 }
2499 session_proctitle(s); 2483 session_proctitle(s);
2500 session_unused(s->self); 2484 session_unused(s->self);