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:
parent
6bbd7bf3a0
commit
45b3329d9f
@ -400,8 +400,9 @@ Shell::_Spawn(int row, int col, const ShellParameters& parameters)
|
||||
char stringBuffer[256];
|
||||
|
||||
if (argv == NULL || argc == 0) {
|
||||
if (!getpwuid_r(getuid(), &passwdStruct, stringBuffer,
|
||||
sizeof(stringBuffer), &passwdResult)) {
|
||||
if (getpwuid_r(getuid(), &passwdStruct, stringBuffer,
|
||||
sizeof(stringBuffer), &passwdResult) == 0
|
||||
&& passwdResult != NULL) {
|
||||
defaultArgs[0] = passwdStruct.pw_shell;
|
||||
}
|
||||
|
||||
|
@ -381,7 +381,8 @@ find_directory(directory_which which, dev_t device, bool createIt,
|
||||
struct passwd *pw;
|
||||
|
||||
if (getpwuid_r(geteuid(), &pwBuffer, pwStringBuffer,
|
||||
sizeof(pwStringBuffer), &pw) == 0) {
|
||||
sizeof(pwStringBuffer), &pw) == 0
|
||||
&& pw != NULL) {
|
||||
home = pw->pw_dir;
|
||||
}
|
||||
#endif // USE_PWENTS
|
||||
|
Loading…
Reference in New Issue
Block a user