summaryrefslogtreecommitdiffstats
path: root/usr.bin/ssh/sshconnect2.c
diff options
context:
space:
mode:
authorprovos <provos@openbsd.org>2000-10-19 16:45:16 +0000
committerprovos <provos@openbsd.org>2000-10-19 16:45:16 +0000
commitc63bcc3dc00918e725e583e95816edc4a661d710 (patch)
treea7dda90578926a0bb598d85f9731402e3bd9bf28 /usr.bin/ssh/sshconnect2.c
parentfmt string problem in unused code (diff)
downloadwireguard-openbsd-c63bcc3dc00918e725e583e95816edc4a661d710.tar.xz
wireguard-openbsd-c63bcc3dc00918e725e583e95816edc4a661d710.zip
don't reference freed memory. okay deraadt@
Diffstat (limited to 'usr.bin/ssh/sshconnect2.c')
-rw-r--r--usr.bin/ssh/sshconnect2.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/usr.bin/ssh/sshconnect2.c b/usr.bin/ssh/sshconnect2.c
index 1f3b5a261d4..6ba23d445c5 100644
--- a/usr.bin/ssh/sshconnect2.c
+++ b/usr.bin/ssh/sshconnect2.c
@@ -23,7 +23,7 @@
*/
#include "includes.h"
-RCSID("$OpenBSD: sshconnect2.c,v 1.26 2000/10/14 12:16:56 markus Exp $");
+RCSID("$OpenBSD: sshconnect2.c,v 1.27 2000/10/19 16:45:16 provos Exp $");
#include <openssl/bn.h>
#include <openssl/rsa.h>
@@ -979,7 +979,7 @@ authmethod_lookup(const char *name)
Authmethod *
authmethod_get(char *authlist)
{
- char *name = NULL;
+ char *name = NULL, *authname_old;
Authmethod *method = NULL;
/* Use a suitable default if we're passed a nil list. */
@@ -1013,16 +1013,17 @@ authmethod_get(char *authlist)
method = NULL;
}
- if (authname_current != NULL)
- xfree(authname_current);
-
+ authname_old = authname_current;
if (method != NULL) {
debug("next auth method to try is %s", name);
authname_current = xstrdup(name);
- return method;
} else {
debug("no more auth methods to try");
authname_current = NULL;
- return NULL;
}
+
+ if (authname_old != NULL)
+ xfree(authname_old);
+
+ return (method);
}