lint: replace getpwname() with getpwnam_r()

This commit is contained in:
Kurtis Rader
2017-05-09 22:23:32 -07:00
parent 9b78857894
commit a92a7cbb9c
2 changed files with 14 additions and 8 deletions

View File

@@ -1178,11 +1178,14 @@ static void expand_home_directory(wcstring &input) {
} else {
// Some other users home directory.
std::string name_cstr = wcs2string(username);
struct passwd *userinfo = getpwnam(name_cstr.c_str());
if (userinfo == NULL) {
struct passwd userinfo;
struct passwd *result;
char buf[8192];
int retval = getpwnam_r(name_cstr.c_str(), &userinfo, buf, sizeof(buf), &result);
if (retval || !result) {
tilde_error = true;
} else {
home = str2wcstring(userinfo->pw_dir);
home = str2wcstring(userinfo.pw_dir);
}
}