From efa498fd5db4218ed1c2b735a9402568d51458a1 Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Sun, 21 Mar 2010 12:20:44 -0400 Subject: [PATCH] See if $HOME is bogus, and if so, use getpwuid() instead. Should fully fix http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=553174 --- src/platform_posix.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/platform_posix.c b/src/platform_posix.c index 15c8be6f..10e3f7a9 100644 --- a/src/platform_posix.c +++ b/src/platform_posix.c @@ -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 */