summaryrefslogtreecommitdiff
path: root/usr.bin/expand/expand.c
diff options
context:
space:
mode:
authorMoritz Jodeit <moritz@cvs.openbsd.org>2005-12-27 19:19:56 +0000
committerMoritz Jodeit <moritz@cvs.openbsd.org>2005-12-27 19:19:56 +0000
commitef2fb683d566132fb4b1b9ff039c7204a976c2ad (patch)
tree1ed00e33950eb69b1ab718651227a2f5feb462a4 /usr.bin/expand/expand.c
parent594dd9ff763b5fcb8d4e8762799572c0f49cfb4f (diff)
fix possible overflow in the tabstops[] array. ok miod@
Diffstat (limited to 'usr.bin/expand/expand.c')
-rw-r--r--usr.bin/expand/expand.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/usr.bin/expand/expand.c b/usr.bin/expand/expand.c
index 81e6deedb22..3e36855bd62 100644
--- a/usr.bin/expand/expand.c
+++ b/usr.bin/expand/expand.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: expand.c,v 1.9 2005/03/08 23:30:50 cloder Exp $ */
+/* $OpenBSD: expand.c,v 1.10 2005/12/27 19:19:55 moritz Exp $ */
/* $NetBSD: expand.c,v 1.5 1995/09/02 06:19:46 jtc Exp $ */
/*
@@ -40,7 +40,7 @@ static const char copyright[] =
#if 0
static const char sccsid[] = "@(#)expand.c 8.1 (Berkeley) 6/9/93";
#endif
-static const char rcsid[] = "$OpenBSD: expand.c,v 1.9 2005/03/08 23:30:50 cloder Exp $";
+static const char rcsid[] = "$OpenBSD: expand.c,v 1.10 2005/12/27 19:19:55 moritz Exp $";
#endif /* not lint */
#include <stdio.h>
@@ -160,6 +160,8 @@ bad:
}
if (nstops > 0 && i <= tabstops[nstops-1])
goto bad;
+ if (nstops >= sizeof(tabstops) / sizeof(tabstops[0]))
+ errx(1, "Too many tab stops");
tabstops[nstops++] = i;
if (*cp == 0)
break;