summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>1997-02-09 18:55:17 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>1997-02-09 18:55:17 +0000
commit3505799656dc8cf4ebe42c9cb798e1125e1b48bf (patch)
tree97ef81343063c8c606b6fcc71485da69992b7e7c
parent6d7a44aa357b07f5e71c657535da5adf0c9787aa (diff)
unexploitable buf oflow, eivind@freebsd
-rw-r--r--sbin/restore/symtab.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/sbin/restore/symtab.c b/sbin/restore/symtab.c
index 21b6437402b..d877e12cba7 100644
--- a/sbin/restore/symtab.c
+++ b/sbin/restore/symtab.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: symtab.c,v 1.3 1996/12/04 01:41:53 deraadt Exp $ */
+/* $OpenBSD: symtab.c,v 1.4 1997/02/09 18:55:16 deraadt Exp $ */
/* $NetBSD: symtab.c,v 1.9 1996/11/30 18:04:47 cgd Exp $ */
/*
@@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)symtab.c 8.2 (Berkeley) 9/13/94";
#else
-static char rcsid[] = "$OpenBSD: symtab.c,v 1.3 1996/12/04 01:41:53 deraadt Exp $";
+static char rcsid[] = "$OpenBSD: symtab.c,v 1.4 1997/02/09 18:55:16 deraadt Exp $";
#endif
#endif /* not lint */
@@ -157,8 +157,11 @@ lookupname(name)
cp = name;
for (ep = lookupino(ROOTINO); ep != NULL; ep = ep->e_entries) {
- for (np = buf; *cp != '/' && *cp != '\0'; )
+ for (np = buf;
+ *cp != '/' && *cp != '\0' && np < &buf[sizeof(buf)]; )
*np++ = *cp++;
+ if (np == &buf[sizeof(buf)])
+ break;
*np = '\0';
for ( ; ep != NULL; ep = ep->e_sibling)
if (strcmp(ep->e_name, buf) == 0)