diff options
author | 2015-09-04 08:21:47 +0000 | |
---|---|---|
committer | 2015-09-04 08:21:47 +0000 | |
commit | ff1c583062953388d800def504e3e93992da04af (patch) | |
tree | 9be8b1c7014193f21006d684126d3e6c0c79be88 /usr.bin/ssh/ssh.c | |
parent | Fix mbuf memory accounting after recent *8 pool size change. (diff) | |
download | wireguard-openbsd-ff1c583062953388d800def504e3e93992da04af.tar.xz wireguard-openbsd-ff1c583062953388d800def504e3e93992da04af.zip |
Plug minor memory leaks when options are used more than once. bz#2182,
patch from Tiago Cunha, ok deraadt djm
Diffstat (limited to 'usr.bin/ssh/ssh.c')
-rw-r--r-- | usr.bin/ssh/ssh.c | 15 |
1 files changed, 8 insertions, 7 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); |