From: Quentin Rameau Date: Sat, 21 Sep 2019 18:50:21 +0000 (+0200) Subject: chsh: replace getpw unsafe functions with xgetpw X-Git-Tag: v2.35-rc1~191 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=83db544ddab2b7f8f4189881d8d6c4d56712a10a;p=thirdparty%2Futil-linux.git chsh: replace getpw unsafe functions with xgetpw --- 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);