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:
Xi Wang
2012-09-26 22:27:24 -04:00
parent 815aff9a73
commit f0d9cb3db3
+1 -1
View File
@@ -747,7 +747,7 @@ void chdir_homedir( void )
struct passwd *pw = getpwuid( geteuid() );
if ( pw == NULL ) {
perror( "getpwuid" );
/* non-fatal */
return; /* non-fatal */
}
if ( chdir( pw->pw_dir ) < 0 ) {