summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDamien Miller <djm@cvs.openbsd.org>2022-02-25 02:09:28 +0000
committerDamien Miller <djm@cvs.openbsd.org>2022-02-25 02:09:28 +0000
commitd7dbd6bba3b4255405f09eebb5f7131b91282b09 (patch)
tree93641005fbba556e663a094725c872faa937b879
parent86a8d72fcd776954bb8c7d17ca2409bfd4a139e2 (diff)
save an unneccessary alloc/free, based on patch from
Martin Vahlensieck; ok dtucker@
-rw-r--r--usr.bin/ssh/monitor.c11
1 files changed, 4 insertions, 7 deletions
diff --git a/usr.bin/ssh/monitor.c b/usr.bin/ssh/monitor.c
index 3e4abfbfcce..baaa6219bbf 100644
--- a/usr.bin/ssh/monitor.c
+++ b/usr.bin/ssh/monitor.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: monitor.c,v 1.231 2022/01/28 06:18:42 guenther Exp $ */
+/* $OpenBSD: monitor.c,v 1.232 2022/02/25 02:09:27 djm Exp $ */
/*
* Copyright 2002 Niels Provos <provos@citi.umich.edu>
* Copyright 2002 Markus Friedl <markus@openbsd.org>
@@ -643,7 +643,6 @@ mm_answer_sign(struct ssh *ssh, int sock, struct sshbuf *m)
int
mm_answer_pwnamallow(struct ssh *ssh, int sock, struct sshbuf *m)
{
- char *username;
struct passwd *pwent;
int r, allowed = 0;
u_int i;
@@ -653,14 +652,12 @@ mm_answer_pwnamallow(struct ssh *ssh, int sock, struct sshbuf *m)
if (authctxt->attempt++ != 0)
fatal_f("multiple attempts for getpwnam");
- if ((r = sshbuf_get_cstring(m, &username, NULL)) != 0)
+ if ((r = sshbuf_get_cstring(m, &authctxt->user, NULL)) != 0)
fatal_fr(r, "parse");
- pwent = getpwnamallow(ssh, username);
+ pwent = getpwnamallow(ssh, authctxt->user);
- authctxt->user = xstrdup(username);
- setproctitle("%s [priv]", pwent ? username : "unknown");
- free(username);
+ setproctitle("%s [priv]", pwent ? authctxt->user : "unknown");
sshbuf_reset(m);