NTFS after phk's changes

Gary Jennejohn garyj at jennejohn.org
Tue Dec 7 06:34:02 PST 2004


NTFS is unusable after phk's changes. Mounting an NTFS file system
results in a panic.

Line 336 in /sys/fs/ntfs/ntfs_vfsops.c is the culprit:

	ntfs_u28_init(ntmp, NULL, cs_local, cs_ntfs);

Passing NULL causes the panic because ntfs_u28_init() dereferences the
pointer without checking whether it's NULL.

With the (hopefully) attached patch I can at least mount and ls a
NTFS file system, which is about all that could be done prior to phk's
modifications.

The handling of (p == NULL) in ntfs_u28() is questionable, but it works
for my test case.

--------
Gary Jennejohn / garyj[at]jennejohn.org gj[at]freebsd.org garyj[at]denx.de

-------------- next part --------------
--- /sys/fs/ntfs/ntfs_subr.c.orig	Tue Dec  7 13:17:33 2004
+++ /sys/fs/ntfs/ntfs_subr.c	Tue Dec  7 13:17:10 2004
@@ -2049,6 +2049,10 @@
 		return (0);
 	}
 
+	/* prevent a panic */
+	if (u2w == NULL)
+		return (0);
+
 	MALLOC(u28, char **, 256 * sizeof(char*), M_TEMP, M_WAITOK | M_ZERO);
 
 	for (i=0; i<256; i++) {
--- /sys/fs/ntfs/ntfs_subr.c.orig	Tue Dec  7 13:46:54 2004
+++ /sys/fs/ntfs/ntfs_subr.c	Tue Dec  7 14:59:06 2004
@@ -2168,9 +2168,10 @@
 		return ('?');
 	}
 
-	p = ntmp->ntm_u28[(wc>>8)&0xFF];
+	/* prevent a panic */
+	p = ntmp->ntm_u28?ntmp->ntm_u28[(wc>>8)&0xFF]:NULL;
 	if (p == NULL)
-		return ('_');
+		return (wc);
 	return (p[wc&0xFF]&0xFF);
 }
 


More information about the freebsd-current mailing list