diff options
author | Todd C. Miller <millert@cvs.openbsd.org> | 1996-10-27 16:49:18 +0000 |
---|---|---|
committer | Todd C. Miller <millert@cvs.openbsd.org> | 1996-10-27 16:49:18 +0000 |
commit | f68f31e3a344327980c1e067535f6ad37efd20bd (patch) | |
tree | e6386cd73c2016c69fb37003814c2f125c319881 /usr.bin | |
parent | 9ac1cc488282ac79ce2be797b6a308e669e7dcda (diff) |
Don't use "user" arg verbatim from argv, use the sanitized one in
struct passwd just to be safe.
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/su/su.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/usr.bin/su/su.c b/usr.bin/su/su.c index 5dfa6a37e21..563a1642f66 100644 --- a/usr.bin/su/su.c +++ b/usr.bin/su/su.c @@ -1,4 +1,4 @@ -/* $OpenBSD: su.c,v 1.15 1996/10/26 03:19:31 millert Exp $ */ +/* $OpenBSD: su.c,v 1.16 1996/10/27 16:49:17 millert Exp $ */ /* * Copyright (c) 1988 The Regents of the University of California. @@ -41,7 +41,7 @@ char copyright[] = #ifndef lint /*static char sccsid[] = "from: @(#)su.c 5.26 (Berkeley) 7/6/91";*/ -static char rcsid[] = "$OpenBSD: su.c,v 1.15 1996/10/26 03:19:31 millert Exp $"; +static char rcsid[] = "$OpenBSD: su.c,v 1.16 1996/10/27 16:49:17 millert Exp $"; #endif /* not lint */ #include <sys/param.h> @@ -154,6 +154,8 @@ main(argc, argv) if ((pwd = getpwnam(user)) == NULL) errx(1, "unknown login %s", user); + if ((user = strdup(pwd->pw_name)) == NULL) + err(1, "can't allocate memory"); if (ruid) { #ifdef KERBEROS |