]> git.ipfire.org Git - thirdparty/openssh-portable.git/commitdiff
upstream commit
authordtucker@openbsd.org <dtucker@openbsd.org>
Fri, 4 Sep 2015 08:21:47 +0000 (08:21 +0000)
committerDamien Miller <djm@mindrot.org>
Fri, 11 Sep 2015 03:28:00 +0000 (13:28 +1000)
Plug minor memory leaks when options are used more than
 once.  bz#2182, patch from Tiago Cunha, ok deraadt djm

Upstream-ID: 5b84d0401e27fe1614c10997010cc55933adb48e

ssh.c
sshd.c

diff --git a/ssh.c b/ssh.c
index 6053db2194a64524444766d3df839ae5bbc1e4c0..bf8c9c646ed659a27a92980f151345b0f766982e 100644 (file)
--- a/ssh.c
+++ b/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
@@ -627,7 +627,7 @@ main(int ac, char **av)
                        use_syslog = 1;
                        break;
                case 'E':
-                       logfile = xstrdup(optarg);
+                       logfile = optarg;
                        break;
                case 'G':
                        config_test = 1;
@@ -714,6 +714,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");
@@ -798,6 +799,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;
@@ -817,9 +819,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);
@@ -980,10 +983,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/sshd.c b/sshd.c
index 65ef7e8507068d4967b6941aa0b120322944a026..d86808912f2ac393c17c49720f9ecd70107c5b16 100644 (file)
--- a/sshd.c
+++ b/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
@@ -1530,7 +1530,7 @@ main(int ac, char **av)
                        no_daemon_flag = 1;
                        break;
                case 'E':
-                       logfile = xstrdup(optarg);
+                       logfile = optarg;
                        /* FALLTHROUGH */
                case 'e':
                        log_stderr = 1;
@@ -1632,10 +1632,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)