Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
See if $HOME is bogus, and if so, use getpwuid() instead.
  • Loading branch information
icculus committed Mar 21, 2010
1 parent 72b232d commit efa498f
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/platform_posix.c
Expand Up @@ -97,8 +97,21 @@ char *__PHYSFS_platformGetUserName(void)
char *__PHYSFS_platformGetUserDir(void)
{
char *retval = __PHYSFS_platformCopyEnvironmentVariable("HOME");

/* if the environment variable was set, make sure it's really a dir. */
if (retval != NULL)
{
struct stat statbuf;
if ((stat(retval, &statbuf) == -1) || (S_ISDIR(statbuf.st_mode) == 0))
{
allocator.Free(retval);
retval = NULL;
} /* if */
} /* if */

if (retval == NULL)
retval = getUserDirByUID();

return retval;
} /* __PHYSFS_platformGetUserDir */

Expand Down

0 comments on commit efa498f

Please sign in to comment.