DragonFlyBSD Kernel Audit
DF-0908 / fix.diff
← back to finding ↓ download raw
diff --git a/sys/vfs/dirfs/dirfs_vfsops.c b/sys/vfs/dirfs/dirfs_vfsops.c
--- a/sys/vfs/dirfs/dirfs_vfsops.c
+++ b/sys/vfs/dirfs/dirfs_vfsops.c
@@ -135,7 +135,7 @@
 
 	/* Strip / character at the end to avoid problems */
 	nlen = strnlen(dmp->dm_path, MAXPATHLEN);
-	if (dmp->dm_path[nlen-1] == '/')
+	if (nlen > 0 && dmp->dm_path[nlen-1] == '/')
 		dmp->dm_path[nlen-1] = 0;
 
 	/* Make sure host directory exists and it is indeed a directory. */