Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/netbsd-7]: src/sys/fs/ntfs Pull up following revision(s) (requested by m...



details:   https://anonhg.NetBSD.org/src/rev/bd1d0e111d3f
branches:  netbsd-7
changeset: 798985:bd1d0e111d3f
user:      snj <snj%NetBSD.org@localhost>
date:      Sat Feb 14 08:11:07 2015 +0000

description:
Pull up following revision(s) (requested by maxv in ticket #513):
        sys/fs/ntfs/ntfs_vfsops.c: revision 1.99, 1.100
        sys/fs/ntfs/ntfs_subr.c: revision 1.59
Ensure bps != 0 to prevent a division by zero. Zero byte per sector makes
no sense.
--
Prevent another division by zero in ntfs_loadntnode() by ensuring
spc != 0.
--
Fix a node leak.
Sent on tech-kern@, tested by martin@

diffstat:

 sys/fs/ntfs/ntfs_subr.c   |  26 ++++++++++++++++----------
 sys/fs/ntfs/ntfs_vfsops.c |  15 +++++++++++++--
 2 files changed, 29 insertions(+), 12 deletions(-)

diffs (111 lines):

diff -r 1cf6f82ff691 -r bd1d0e111d3f sys/fs/ntfs/ntfs_subr.c
--- a/sys/fs/ntfs/ntfs_subr.c   Sat Feb 14 08:03:05 2015 +0000
+++ b/sys/fs/ntfs/ntfs_subr.c   Sat Feb 14 08:11:07 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ntfs_subr.c,v 1.51 2013/06/28 17:13:34 matt Exp $      */
+/*     $NetBSD: ntfs_subr.c,v 1.51.8.1 2015/02/14 08:11:07 snj Exp $   */
 
 /*-
  * Copyright (c) 1998, 1999 Semen Ustimenko (semenu%FreeBSD.org@localhost)
@@ -29,7 +29,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ntfs_subr.c,v 1.51 2013/06/28 17:13:34 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ntfs_subr.c,v 1.51.8.1 2015/02/14 08:11:07 snj Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -865,9 +865,9 @@
 {
        struct fnode   *fp = VTOF(vp);
        struct ntnode  *ip = FTONT(fp);
-       struct ntvattr *vap;    /* Root attribute */
+       struct ntvattr *vap = NULL;     /* Root attribute */
        cn_t            cn = 0; /* VCN in current attribute */
-       void *        rdbuf;    /* Buffer to read directory's blocks  */
+       void *        rdbuf = NULL;     /* Buffer to read directory's blocks  */
        u_int32_t       blsize;
        u_int32_t       rdsize; /* Length of data to read from current block */
        struct attr_indexentry *iep;
@@ -887,8 +887,10 @@
                return (error);
 
        error = ntfs_ntvattrget(ntmp, ip, NTFS_A_INDXROOT, "$I30", 0, &vap);
-       if (error || (vap->va_flag & NTFS_AF_INRUN))
-               return (ENOTDIR);
+       if (error || (vap->va_flag & NTFS_AF_INRUN)) {
+               error = ENOTDIR;
+               goto fail;
+       }
 
        /*
         * Divide file name into: foofilefoofilefoofile[:attrspec]
@@ -1114,9 +1116,11 @@
                        free(tctx, M_TEMP);
                }
        }
-       ntfs_ntvattrrele(vap);
+       if (vap)
+               ntfs_ntvattrrele(vap);
+       if (rdbuf)
+               free(rdbuf, M_TEMP);
        ntfs_ntput(ip);
-       free(rdbuf, M_TEMP);
        return (error);
 }
 
@@ -1182,8 +1186,10 @@
                return (error);
 
        error = ntfs_ntvattrget(ntmp, ip, NTFS_A_INDXROOT, "$I30", 0, &vap);
-       if (error)
-               return (ENOTDIR);
+       if (error) {
+               error = ENOTDIR;
+               goto fail;
+       }
 
        if (fp->f_dirblbuf == NULL) {
                fp->f_dirblsz = vap->va_a_iroot->ir_size;
diff -r 1cf6f82ff691 -r bd1d0e111d3f sys/fs/ntfs/ntfs_vfsops.c
--- a/sys/fs/ntfs/ntfs_vfsops.c Sat Feb 14 08:03:05 2015 +0000
+++ b/sys/fs/ntfs/ntfs_vfsops.c Sat Feb 14 08:11:07 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ntfs_vfsops.c,v 1.94 2014/04/16 18:55:18 maxv Exp $    */
+/*     $NetBSD: ntfs_vfsops.c,v 1.94.2.1 2015/02/14 08:11:07 snj Exp $ */
 
 /*-
  * Copyright (c) 1998, 1999 Semen Ustimenko
@@ -29,7 +29,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ntfs_vfsops.c,v 1.94 2014/04/16 18:55:18 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ntfs_vfsops.c,v 1.94.2.1 2015/02/14 08:11:07 snj Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -331,11 +331,22 @@
        brelse( bp , 0 );
        bp = NULL;
 
+       /* Sanity checks. XXX: More checks are probably needed. */
        if (strncmp(ntmp->ntm_bootfile.bf_sysid, NTFS_BBID, NTFS_BBIDLEN)) {
                error = EINVAL;
                dprintf(("ntfs_mountfs: invalid boot block\n"));
                goto out;
        }
+       if (ntmp->ntm_bps == 0) {
+               error = EINVAL;
+               dprintf(("ntfs_mountfs: invalid bytes per sector\n"));
+               goto out;
+       }
+       if (ntmp->ntm_spc == 0) {
+               error = EINVAL;
+               dprintf(("ntfs_mountfs: invalid sectors per cluster\n"));
+               goto out;
+       }
 
        {
                int8_t cpr = ntmp->ntm_mftrecsz;



Home | Main Index | Thread Index | Old Index