Fix for freebsd qmlfrontend
authorunc0rr
Sun, 14 Jan 2018 23:30:42 +0100
branchqmlfrontend
changeset 12892 0088bcccd19a
parent 12890 9c259fb4d405
child 13772 5c0ea888c926
Fix for freebsd
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 <errno.h>
 #include <limits.h>
 
+#include <sys/types.h>
+#include <sys/sysctl.h>
+
+
 #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
     {