summaryrefslogtreecommitdiff
path: root/sbin/disklabel
diff options
context:
space:
mode:
authorchristos <christos@NetBSD.org>2013-05-13 17:58:50 +0000
committerchristos <christos@NetBSD.org>2013-05-13 17:58:50 +0000
commit46f642181d268b40774b899fe28390116244a3da (patch)
treeda6112c46a1876356e65a1833e6e9bf164975588 /sbin/disklabel
parent61b0ab89f56d9e390e708188fd1591e03ed82744 (diff)
CVE 1020935: Prevent overflow
Diffstat (limited to 'sbin/disklabel')
-rw-r--r--sbin/disklabel/main.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/sbin/disklabel/main.c b/sbin/disklabel/main.c
index 13bb8905aa9..b05b379bece 100644
--- a/sbin/disklabel/main.c
+++ b/sbin/disklabel/main.c
@@ -1,4 +1,4 @@
-/* $NetBSD: main.c,v 1.32 2013/05/05 15:59:42 skrll Exp $ */
+/* $NetBSD: main.c,v 1.33 2013/05/13 17:58:50 christos Exp $ */
/*
* Copyright (c) 2006 The NetBSD Foundation, Inc.
@@ -76,7 +76,7 @@ __COPYRIGHT("@(#) Copyright (c) 1987, 1993\
static char sccsid[] = "@(#)disklabel.c 8.4 (Berkeley) 5/4/95";
/* from static char sccsid[] = "@(#)disklabel.c 1.2 (Symmetric) 11/28/85"; */
#else
-__RCSID("$NetBSD: main.c,v 1.32 2013/05/05 15:59:42 skrll Exp $");
+__RCSID("$NetBSD: main.c,v 1.33 2013/05/13 17:58:50 christos Exp $");
#endif
#endif /* not lint */
@@ -1835,6 +1835,12 @@ getasciilabel(FILE *f, struct disklabel *lp)
errors++;
continue;
}
+ if (part >= __arraycount(lp->d_partitions)) {
+ warnx("line %d: partition id %s, >= %zu", lineno,
+ cp, __arraycount(lp->d_partitions));
+ errors++;
+ continue;
+ }
pp = &lp->d_partitions[part];
NXTXNUM(pp->p_size);