diff options
author | Darren Tucker <dtucker@cvs.openbsd.org> | 2015-09-04 08:21:48 +0000 |
---|---|---|
committer | Darren Tucker <dtucker@cvs.openbsd.org> | 2015-09-04 08:21:48 +0000 |
commit | 3329517806969b15b0dbe4ca265bbe649c3aef4a (patch) | |
tree | f6975fae785f14cc3ddbf73f979a06a7bd7f51cf | |
parent | ad6e33f9ecbc065999d8db0b0efa03c8c09c85a1 (diff) |
Plug minor memory leaks when options are used more than once. bz#2182,
patch from Tiago Cunha, ok deraadt djm
-rw-r--r-- | usr.bin/ssh/ssh.c | 15 | ||||
-rw-r--r-- | usr.bin/ssh/sshd.c | 8 |
2 files changed, 11 insertions, 12 deletions
diff --git a/usr.bin/ssh/ssh.c b/usr.bin/ssh/ssh.c index ae2107cc768..f24ff57cac9 100644 --- a/usr.bin/ssh/ssh.c +++ b/usr.bin/ssh/ssh.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ssh.c,v 1.421 2015/09/04 04:56:09 djm Exp $ */ +/* $OpenBSD: ssh.c,v 1.422 2015/09/04 08:21:47 dtucker Exp $ */ /* * Author: Tatu Ylonen <ylo@cs.hut.fi> * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland @@ -597,7 +597,7 @@ main(int ac, char **av) use_syslog = 1; break; case 'E': - logfile = xstrdup(optarg); + logfile = optarg; break; case 'G': config_test = 1; @@ -684,6 +684,7 @@ main(int ac, char **av) break; case 'I': #ifdef ENABLE_PKCS11 + free(options.pkcs11_provider); options.pkcs11_provider = xstrdup(optarg); #else fprintf(stderr, "no support for PKCS#11.\n"); @@ -768,6 +769,7 @@ main(int ac, char **av) if (ciphers_valid(*optarg == '+' ? optarg + 1 : optarg)) { /* SSH2 only */ + free(options.ciphers); options.ciphers = xstrdup(optarg); options.cipher = SSH_CIPHER_INVALID; break; @@ -787,9 +789,10 @@ main(int ac, char **av) options.ciphers = xstrdup(KEX_CLIENT_ENCRYPT); break; case 'm': - if (mac_valid(optarg)) + if (mac_valid(optarg)) { + free(options.macs); options.macs = xstrdup(optarg); - else { + } else { fprintf(stderr, "Unknown mac type '%s'\n", optarg); exit(255); @@ -950,10 +953,8 @@ main(int ac, char **av) */ if (use_syslog && logfile != NULL) fatal("Can't specify both -y and -E"); - if (logfile != NULL) { + if (logfile != NULL) log_redirect_stderr_to(logfile); - free(logfile); - } log_init(argv0, options.log_level == -1 ? SYSLOG_LEVEL_INFO : options.log_level, SYSLOG_FACILITY_USER, !use_syslog); diff --git a/usr.bin/ssh/sshd.c b/usr.bin/ssh/sshd.c index d4ebbbd001d..a9df666fe8e 100644 --- a/usr.bin/ssh/sshd.c +++ b/usr.bin/ssh/sshd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sshd.c,v 1.458 2015/08/20 22:32:42 deraadt Exp $ */ +/* $OpenBSD: sshd.c,v 1.459 2015/09/04 08:21:47 dtucker Exp $ */ /* * Author: Tatu Ylonen <ylo@cs.hut.fi> * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland @@ -1446,7 +1446,7 @@ main(int ac, char **av) no_daemon_flag = 1; break; case 'E': - logfile = xstrdup(optarg); + logfile = optarg; /* FALLTHROUGH */ case 'e': log_stderr = 1; @@ -1548,10 +1548,8 @@ main(int ac, char **av) #endif /* If requested, redirect the logs to the specified logfile. */ - if (logfile != NULL) { + if (logfile != NULL) log_redirect_stderr_to(logfile); - free(logfile); - } /* * Force logging to stderr until we have loaded the private host * key (unless started from inetd) |