Source-Changes-HG archive

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

[src/trunk]: src/sys/ufs/ffs Fix a "slight tweak" from Rev. 1.121: bap1/bap2...



details:   https://anonhg.NetBSD.org/src/rev/f9a12c3920d2
branches:  trunk
changeset: 348844:f9a12c3920d2
user:      hannken <hannken%NetBSD.org@localhost>
date:      Fri Nov 11 10:50:16 2016 +0000

description:
Fix a "slight tweak" from Rev. 1.121:  bap1/bap2 must be valid
before using BAP_ASSIGN().

Prevents NULL pointer dereference when "lastbn >= 0".

diffstat:

 sys/ufs/ffs/ffs_inode.c |  13 ++++++-------
 1 files changed, 6 insertions(+), 7 deletions(-)

diffs (41 lines):

diff -r c056abbb4834 -r f9a12c3920d2 sys/ufs/ffs/ffs_inode.c
--- a/sys/ufs/ffs/ffs_inode.c   Fri Nov 11 10:40:00 2016 +0000
+++ b/sys/ufs/ffs/ffs_inode.c   Fri Nov 11 10:50:16 2016 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ffs_inode.c,v 1.122 2016/11/10 20:56:32 jdolecek Exp $ */
+/*     $NetBSD: ffs_inode.c,v 1.123 2016/11/11 10:50:16 hannken Exp $  */
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -61,7 +61,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ffs_inode.c,v 1.122 2016/11/10 20:56:32 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ffs_inode.c,v 1.123 2016/11/11 10:50:16 hannken Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_ffs.h"
@@ -659,6 +659,10 @@
         * This assumes the truncate process would not fail, contrary
         * to the wapbl case.
         */
+       if (ip->i_ump->um_fstype == UFS1)
+               bap1 = (int32_t *)bp->b_data;
+       else
+               bap2 = (int64_t *)bp->b_data;
        if (lastbn >= 0 && !wapbl) {
                copy = kmem_alloc(fs->fs_bsize, KM_SLEEP);
                memcpy((void *)copy, bp->b_data, (u_int)fs->fs_bsize);
@@ -672,11 +676,6 @@
                        bap1 = (int32_t *)copy;
                else
                        bap2 = (int64_t *)copy;
-       } else {
-               if (ip->i_ump->um_fstype == UFS1)
-                       bap1 = (int32_t *)bp->b_data;
-               else
-                       bap2 = (int64_t *)bp->b_data;
        }
 
        /*



Home | Main Index | Thread Index | Old Index