diff options
author | mestre <mestre@openbsd.org> | 2018-09-26 14:54:58 +0000 |
---|---|---|
committer | mestre <mestre@openbsd.org> | 2018-09-26 14:54:58 +0000 |
commit | 636b7295b9723ec6d11cd94a6387ec2309cf2c46 (patch) | |
tree | 766e8c412424373e6856163e781d887c4fff4eea | |
parent | Fix use-after-free by moving the free(3) of the configured interfaces to after (diff) | |
download | wireguard-openbsd-636b7295b9723ec6d11cd94a6387ec2309cf2c46.tar.xz wireguard-openbsd-636b7295b9723ec6d11cd94a6387ec2309cf2c46.zip |
Fix segfault in usermod -l by swapping one of the getpwnam(3) with
uid_from_user(3). This started happening a few days ago after the change to
the pwcache in libc.
OK millert@
-rw-r--r-- | usr.sbin/user/user.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/usr.sbin/user/user.c b/usr.sbin/user/user.c index d8c1b34a3ef..077d76c618c 100644 --- a/usr.sbin/user/user.c +++ b/usr.sbin/user/user.c @@ -1,4 +1,4 @@ -/* $OpenBSD: user.c,v 1.121 2018/09/13 15:23:32 millert Exp $ */ +/* $OpenBSD: user.c,v 1.122 2018/09/26 14:54:58 mestre Exp $ */ /* $NetBSD: user.c,v 1.69 2003/04/14 17:40:07 agc Exp $ */ /* @@ -1369,6 +1369,7 @@ moduser(char *login_name, char *newlogin, user_t *up) int ptmpfd; int rval; int i; + uid_t uid; if (!valid_login(newlogin)) { errx(EXIT_FAILURE, "`%s' is not a valid login name", login_name); @@ -1427,7 +1428,8 @@ moduser(char *login_name, char *newlogin, user_t *up) if (up != NULL) { if (up->u_flags & F_USERNAME) { /* if changing name, check new name isn't already in use */ - if (strcmp(login_name, newlogin) != 0 && getpwnam(newlogin) != NULL) { + if (strcmp(login_name, newlogin) != 0 && + uid_from_user(newlogin, &uid) != -1) { close(ptmpfd); pw_abort(); errx(EXIT_FAILURE, "already a `%s' user", newlogin); |