(+initialize) [PROCFS_EXE_LINK]: Make sure that the link is a path before using it.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@16131 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
alexm 2003-03-05 14:53:21 +00:00
parent 1418e4efd8
commit afc3fc9316
2 changed files with 18 additions and 0 deletions

View file

@ -585,6 +585,19 @@ _bundle_load_callback(Class theClass, struct objc_category *theCategory)
_executable_path = [[NSFileManager defaultManager]
pathContentOfSymbolicLinkAtPath:
[NSString stringWithCString: PROCFS_EXE_LINK]];
/*
On some systems, the link is of the form "[device]:inode", which
can be used to open the executable, but is useless if you want
the path to it. Thus we check that the path is an actual absolute
path. (Using '/' here is safe; it isn't the path separator
everywhere, but it is on all systems that have PROCFS_EXE_LINK.)
*/
if ([_executable_path length] > 0 &&
[_executable_path characterAtIndex: 0] != '/')
{
_executable_path = nil;
}
#endif
if (_executable_path == nil || [_executable_path length] == 0)
{