From 83db544ddab2b7f8f4189881d8d6c4d56712a10a Mon Sep 17 00:00:00 2001 From: Quentin Rameau Date: Sat, 21 Sep 2019 20:50:21 +0200 Subject: [PATCH] chsh: replace getpw unsafe functions with xgetpw --- login-utils/chsh.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/login-utils/chsh.c b/login-utils/chsh.c index 9b27611573..a9ebec86ff 100644 --- a/login-utils/chsh.c +++ b/login-utils/chsh.c @@ -38,6 +38,7 @@ #include "islocal.h" #include "nls.h" #include "pathnames.h" +#include "pwdutils.h" #include "setpwnam.h" #include "strutils.h" #include "xalloc.h" @@ -253,7 +254,7 @@ static void check_shell(const char *shell) int main(int argc, char **argv) { - char *oldshell; + char *oldshell, *pwbuf; int nullshell = 0; const uid_t uid = getuid(); struct sinfo info = { NULL }; @@ -267,12 +268,12 @@ int main(int argc, char **argv) parse_argv(argc, argv, &info); if (!info.username) { - pw = getpwuid(uid); + pw = xgetpwuid(uid, &pwbuf); if (!pw) errx(EXIT_FAILURE, _("you (user %d) don't exist."), uid); } else { - pw = getpwnam(info.username); + pw = xgetpwnam(info.username, &pwbuf); if (!pw) errx(EXIT_FAILURE, _("user \"%s\" does not exist."), info.username); -- 2.47.3