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.
This commit is contained in:
parent
697a2ce91b
commit
eaa9cbdf28
@ -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 @@ checkparttype(const char *name, int force)
|
||||
|
||||
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));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user