Source-Changes-HG archive

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

[src/trunk]: src/sys/ufs/ffs Don't (harmlessly) overrun di_db array; copy di_...



details:   https://anonhg.NetBSD.org/src/rev/bde463ae8b6a
branches:  trunk
changeset: 808524:bde463ae8b6a
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Wed May 20 18:19:09 2015 +0000

description:
Don't (harmlessly) overrun di_db array; copy di_ib separately.

Noted by Coverity, CID 974635.

While here, simplify size calculation for memcpy.

diffstat:

 sys/ufs/ffs/ffs_bswap.c |  7 ++++---
 1 files changed, 4 insertions(+), 3 deletions(-)

diffs (28 lines):

diff -r c0b6d6ab2298 -r bde463ae8b6a sys/ufs/ffs/ffs_bswap.c
--- a/sys/ufs/ffs/ffs_bswap.c   Wed May 20 18:13:23 2015 +0000
+++ b/sys/ufs/ffs/ffs_bswap.c   Wed May 20 18:19:09 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ffs_bswap.c,v 1.37 2013/06/09 17:55:46 dholland Exp $  */
+/*     $NetBSD: ffs_bswap.c,v 1.38 2015/05/20 18:19:09 riastradh Exp $ */
 
 /*
  * Copyright (c) 1998 Manuel Bouyer.
@@ -30,7 +30,7 @@
 #endif
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ffs_bswap.c,v 1.37 2013/06/09 17:55:46 dholland Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ffs_bswap.c,v 1.38 2015/05/20 18:19:09 riastradh Exp $");
 
 #include <sys/param.h>
 #if defined(_KERNEL)
@@ -128,7 +128,8 @@
        n->di_mtimensec = bswap32(o->di_mtimensec);
        n->di_ctime = bswap32(o->di_ctime);
        n->di_ctimensec = bswap32(o->di_ctimensec);
-       memcpy(n->di_db, o->di_db, (UFS_NDADDR + UFS_NIADDR) * sizeof(u_int32_t));
+       memcpy(n->di_db, o->di_db, sizeof(n->di_db));
+       memcpy(n->di_ib, o->di_ib, sizeof(n->di_ib));
        n->di_flags = bswap32(o->di_flags);
        n->di_blocks = bswap32(o->di_blocks);
        n->di_gen = bswap32(o->di_gen);



Home | Main Index | Thread Index | Old Index