Avoid null pointer dereference in chdir_homedir()
Return if pw is NULL, to avoid dereferencing it at pw->pw_dir.
This commit is contained in:
@@ -747,7 +747,7 @@ void chdir_homedir( void )
|
|||||||
struct passwd *pw = getpwuid( geteuid() );
|
struct passwd *pw = getpwuid( geteuid() );
|
||||||
if ( pw == NULL ) {
|
if ( pw == NULL ) {
|
||||||
perror( "getpwuid" );
|
perror( "getpwuid" );
|
||||||
/* non-fatal */
|
return; /* non-fatal */
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( chdir( pw->pw_dir ) < 0 ) {
|
if ( chdir( pw->pw_dir ) < 0 ) {
|
||||||
|
|||||||
Reference in New Issue
Block a user