Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/x68k/stand/installboot Check lp->d_npartitions befo...



details:   https://anonhg.NetBSD.org/src/rev/7c2cc957da93
branches:  trunk
changeset: 782074:7c2cc957da93
user:      tsutsui <tsutsui%NetBSD.org@localhost>
date:      Sun Oct 14 16:20:04 2012 +0000

description:
Check lp->d_npartitions before calling dkcksum()
(which is in src/sbin/disklabel/dkcksum.c) because
it doesn't check range and could cause coredump during
installboot against floppy that includes garbage in LABELSECTOR.

diffstat:

 sys/arch/x68k/stand/installboot/installboot.c |  5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)

diffs (19 lines):

diff -r ca94d00736d5 -r 7c2cc957da93 sys/arch/x68k/stand/installboot/installboot.c
--- a/sys/arch/x68k/stand/installboot/installboot.c     Sun Oct 14 16:16:52 2012 +0000
+++ b/sys/arch/x68k/stand/installboot/installboot.c     Sun Oct 14 16:20:04 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: installboot.c,v 1.5 2006/09/23 20:10:14 pavel Exp $    */
+/*     $NetBSD: installboot.c,v 1.6 2012/10/14 16:20:04 tsutsui Exp $  */
 
 /*
  * Copyright (c) 2001 Minoura Makoto
@@ -159,7 +159,8 @@
 
                lp = (struct disklabel *) &bootblock[LABELBYTEOFFSET];
                memcpy(&label, lp, sizeof(struct disklabel));
-               if (dkcksum(lp) != 0)
+               if (lp->d_npartitions > MAXPARTITIONS ||
+                   dkcksum(lp) != 0)
                        /* there is no valid label */
                        memset(&label, 0, sizeof(struct disklabel));
        }



Home | Main Index | Thread Index | Old Index