Fix incorrect uses of getpwuid_r()
The function's behavior was recently fixed to succeed, but return a NULL pointer, when the entry was not found. Fixes a crash in this case.
This commit is contained in:
@@ -400,8 +400,9 @@ Shell::_Spawn(int row, int col, const ShellParameters& parameters)
|
|||||||
char stringBuffer[256];
|
char stringBuffer[256];
|
||||||
|
|
||||||
if (argv == NULL || argc == 0) {
|
if (argv == NULL || argc == 0) {
|
||||||
if (!getpwuid_r(getuid(), &passwdStruct, stringBuffer,
|
if (getpwuid_r(getuid(), &passwdStruct, stringBuffer,
|
||||||
sizeof(stringBuffer), &passwdResult)) {
|
sizeof(stringBuffer), &passwdResult) == 0
|
||||||
|
&& passwdResult != NULL) {
|
||||||
defaultArgs[0] = passwdStruct.pw_shell;
|
defaultArgs[0] = passwdStruct.pw_shell;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -381,7 +381,8 @@ find_directory(directory_which which, dev_t device, bool createIt,
|
|||||||
struct passwd *pw;
|
struct passwd *pw;
|
||||||
|
|
||||||
if (getpwuid_r(geteuid(), &pwBuffer, pwStringBuffer,
|
if (getpwuid_r(geteuid(), &pwBuffer, pwStringBuffer,
|
||||||
sizeof(pwStringBuffer), &pw) == 0) {
|
sizeof(pwStringBuffer), &pw) == 0
|
||||||
|
&& pw != NULL) {
|
||||||
home = pw->pw_dir;
|
home = pw->pw_dir;
|
||||||
}
|
}
|
||||||
#endif // USE_PWENTS
|
#endif // USE_PWENTS
|
||||||
|
|||||||
Reference in New Issue
Block a user