# HG changeset patch # User unc0rr # Date 1515969042 -3600 # Node ID 0088bcccd19a9b39affd787d04f22c316f240207 # Parent 9c259fb4d40501bae4d533608628b22f2e56547f Fix for freebsd diff -r 9c259fb4d405 -r 0088bcccd19a misc/libphysfs/platform_unix.c --- a/misc/libphysfs/platform_unix.c Wed Jan 10 23:49:47 2018 +0100 +++ b/misc/libphysfs/platform_unix.c Sun Jan 14 23:30:42 2018 +0100 @@ -23,6 +23,10 @@ #include #include +#include +#include + + #if PHYSFS_PLATFORM_LINUX && !defined(PHYSFS_HAVE_MNTENT_H) #define PHYSFS_HAVE_MNTENT_H 1 #elif PHYSFS_PLATFORM_SOLARIS && !defined(PHYSFS_HAVE_SYS_MNTTAB_H) @@ -251,10 +255,14 @@ #if PHYSFS_PLATFORM_FREEBSD { char fullpath[PATH_MAX]; - size_t buflen = sizeof (fullpath); + size_t buflen = sizeof (fullpath) - 1; int mib[4] = { CTL_KERN, KERN_PROC, KERN_PROC_PATHNAME, -1 }; - if (sysctl(mib, 4, fullpath, &buflen, NULL, 0) != -1) + if (sysctl(mib, 4, fullpath, &buflen, NULL, 0) != -1) { + int pathlen = strlen(fullpath); + fullpath[pathlen] = '/'; + fullpath[pathlen + 1] = 0; retval = __PHYSFS_strdup(fullpath); + } } #elif PHYSFS_PLATFORM_SOLARIS {