NTFS after phk's changes

From: Gary Jennejohn <garyj_at_jennejohn.org>
Date: Tue, 07 Dec 2004 15:33:59 +0100
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


--- /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
_at__at_ -2049,6 +2049,10 _at__at_
 		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
_at__at_ -2168,9 +2168,10 _at__at_
 		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);
 }
 
Received on Tue Dec 07 2004 - 13:34:02 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:38:24 UTC