DragonFlyBSD Kernel Audit
DF-2555 / fix.diff
← back to finding ↓ download raw
diff --git a/sys/vfs/ntfs/ntfs_vfsops.c b/sys/vfs/ntfs/ntfs_vfsops.c
--- a/sys/vfs/ntfs/ntfs_vfsops.c
+++ b/sys/vfs/ntfs/ntfs_vfsops.c
@@ -454,11 +454,11 @@
 					&ad, NULL);
 			if (error)
 				goto out1;
-			j = 0;
-			do {
+			for (j = 0; j < (int)sizeof(ntmp->ntm_ad[i].ad_name) - 1 &&
+			     ad.ad_name[j] != 0; j++)
 				ntmp->ntm_ad[i].ad_name[j] = ad.ad_name[j];
-			} while(ad.ad_name[j++]);
-			ntmp->ntm_ad[i].ad_namelen = j - 1;
+			ntmp->ntm_ad[i].ad_name[j] = '\0';
+			ntmp->ntm_ad[i].ad_namelen = j;
 			ntmp->ntm_ad[i].ad_type = ad.ad_type;
 		}