Source-Changes-HG archive

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

[src/trunk]: src/sys/fs/ntfs Ensure bps != 0 to prevent a division by zero. Z...



details:   https://anonhg.NetBSD.org/src/rev/05103b1dd9bc
branches:  trunk
changeset: 335162:05103b1dd9bc
user:      maxv <maxv%NetBSD.org@localhost>
date:      Sun Dec 28 12:57:44 2014 +0000

description:
Ensure bps != 0 to prevent a division by zero. Zero byte per sector makes
no sense.

diffstat:

 sys/fs/ntfs/ntfs_vfsops.c |  10 ++++++++--
 1 files changed, 8 insertions(+), 2 deletions(-)

diffs (36 lines):

diff -r 71282de945e0 -r 05103b1dd9bc sys/fs/ntfs/ntfs_vfsops.c
--- a/sys/fs/ntfs/ntfs_vfsops.c Sun Dec 28 12:19:21 2014 +0000
+++ b/sys/fs/ntfs/ntfs_vfsops.c Sun Dec 28 12:57:44 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ntfs_vfsops.c,v 1.98 2014/12/28 12:13:22 maxv Exp $    */
+/*     $NetBSD: ntfs_vfsops.c,v 1.99 2014/12/28 12:57:44 maxv Exp $    */
 
 /*-
  * Copyright (c) 1998, 1999 Semen Ustimenko
@@ -29,7 +29,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ntfs_vfsops.c,v 1.98 2014/12/28 12:13:22 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ntfs_vfsops.c,v 1.99 2014/12/28 12:57:44 maxv Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -324,11 +324,17 @@
        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;
+       }
 
        {
                int8_t cpr = ntmp->ntm_mftrecsz;



Home | Main Index | Thread Index | Old Index