CVE 1020935: Prevent overflow

This commit is contained in:
christos 2013-05-13 17:58:50 +00:00
parent 748fc2c7c9
commit 7d5016218f
1 changed files with 8 additions and 2 deletions

View File

@ -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. * 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"; static char sccsid[] = "@(#)disklabel.c 8.4 (Berkeley) 5/4/95";
/* from static char sccsid[] = "@(#)disklabel.c 1.2 (Symmetric) 11/28/85"; */ /* from static char sccsid[] = "@(#)disklabel.c 1.2 (Symmetric) 11/28/85"; */
#else #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
#endif /* not lint */ #endif /* not lint */
@ -1835,6 +1835,12 @@ getasciilabel(FILE *f, struct disklabel *lp)
errors++; errors++;
continue; 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]; pp = &lp->d_partitions[part];
NXTXNUM(pp->p_size); NXTXNUM(pp->p_size);