diff options
Diffstat (limited to 'mux.c')
-rw-r--r-- | mux.c | 14 |
1 files changed, 10 insertions, 4 deletions
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: mux.c,v 1.34 2012/01/07 21:11:36 djm Exp $ */ | 1 | /* $OpenBSD: mux.c,v 1.36 2012/07/06 01:37:21 djm Exp $ */ |
2 | /* | 2 | /* |
3 | * Copyright (c) 2002-2008 Damien Miller <djm@openbsd.org> | 3 | * Copyright (c) 2002-2008 Damien Miller <djm@openbsd.org> |
4 | * | 4 | * |
@@ -316,6 +316,8 @@ process_mux_new_session(u_int rid, Channel *c, Buffer *m, Buffer *r) | |||
316 | cctx->term = NULL; | 316 | cctx->term = NULL; |
317 | cctx->rid = rid; | 317 | cctx->rid = rid; |
318 | cmd = reserved = NULL; | 318 | cmd = reserved = NULL; |
319 | cctx->env = NULL; | ||
320 | env_len = 0; | ||
319 | if ((reserved = buffer_get_string_ret(m, NULL)) == NULL || | 321 | if ((reserved = buffer_get_string_ret(m, NULL)) == NULL || |
320 | buffer_get_int_ret(&cctx->want_tty, m) != 0 || | 322 | buffer_get_int_ret(&cctx->want_tty, m) != 0 || |
321 | buffer_get_int_ret(&cctx->want_x_fwd, m) != 0 || | 323 | buffer_get_int_ret(&cctx->want_x_fwd, m) != 0 || |
@@ -329,16 +331,19 @@ process_mux_new_session(u_int rid, Channel *c, Buffer *m, Buffer *r) | |||
329 | xfree(cmd); | 331 | xfree(cmd); |
330 | if (reserved != NULL) | 332 | if (reserved != NULL) |
331 | xfree(reserved); | 333 | xfree(reserved); |
334 | for (j = 0; j < env_len; j++) | ||
335 | xfree(cctx->env[j]); | ||
336 | if (env_len > 0) | ||
337 | xfree(cctx->env); | ||
332 | if (cctx->term != NULL) | 338 | if (cctx->term != NULL) |
333 | xfree(cctx->term); | 339 | xfree(cctx->term); |
340 | xfree(cctx); | ||
334 | error("%s: malformed message", __func__); | 341 | error("%s: malformed message", __func__); |
335 | return -1; | 342 | return -1; |
336 | } | 343 | } |
337 | xfree(reserved); | 344 | xfree(reserved); |
338 | reserved = NULL; | 345 | reserved = NULL; |
339 | 346 | ||
340 | cctx->env = NULL; | ||
341 | env_len = 0; | ||
342 | while (buffer_len(m) > 0) { | 347 | while (buffer_len(m) > 0) { |
343 | #define MUX_MAX_ENV_VARS 4096 | 348 | #define MUX_MAX_ENV_VARS 4096 |
344 | if ((cp = buffer_get_string_ret(m, &len)) == NULL) | 349 | if ((cp = buffer_get_string_ret(m, &len)) == NULL) |
@@ -413,6 +418,7 @@ process_mux_new_session(u_int rid, Channel *c, Buffer *m, Buffer *r) | |||
413 | xfree(cctx->env); | 418 | xfree(cctx->env); |
414 | } | 419 | } |
415 | buffer_free(&cctx->cmd); | 420 | buffer_free(&cctx->cmd); |
421 | xfree(cctx); | ||
416 | return 0; | 422 | return 0; |
417 | } | 423 | } |
418 | 424 | ||
@@ -1195,6 +1201,7 @@ muxserver_listen(void) | |||
1195 | close(muxserver_sock); | 1201 | close(muxserver_sock); |
1196 | muxserver_sock = -1; | 1202 | muxserver_sock = -1; |
1197 | } | 1203 | } |
1204 | xfree(orig_control_path); | ||
1198 | xfree(options.control_path); | 1205 | xfree(options.control_path); |
1199 | options.control_path = NULL; | 1206 | options.control_path = NULL; |
1200 | options.control_master = SSHCTL_MASTER_NO; | 1207 | options.control_master = SSHCTL_MASTER_NO; |
@@ -1216,7 +1223,6 @@ muxserver_listen(void) | |||
1216 | } | 1223 | } |
1217 | error("ControlSocket %s already exists, disabling multiplexing", | 1224 | error("ControlSocket %s already exists, disabling multiplexing", |
1218 | orig_control_path); | 1225 | orig_control_path); |
1219 | xfree(orig_control_path); | ||
1220 | unlink(options.control_path); | 1226 | unlink(options.control_path); |
1221 | goto disable_mux_master; | 1227 | goto disable_mux_master; |
1222 | } | 1228 | } |