summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAaron Campbell <aaron@cvs.openbsd.org>2001-06-14 20:38:39 +0000
committerAaron Campbell <aaron@cvs.openbsd.org>2001-06-14 20:38:39 +0000
commitfc6172932d8fdeecc671e7795566fd34da21b853 (patch)
treeca0651f9792958e7c6cbf0132f8ddadada2067e8
parent6ac69f1e74cf3bce9700942db983249fc5d87e52 (diff)
Fix a buf oflow in EXAMPLES code; millert@ ok
-rw-r--r--lib/libc/string/strsep.39
1 files changed, 6 insertions, 3 deletions
diff --git a/lib/libc/string/strsep.3 b/lib/libc/string/strsep.3
index b15915ab376..33cb2803c59 100644
--- a/lib/libc/string/strsep.3
+++ b/lib/libc/string/strsep.3
@@ -1,4 +1,4 @@
-.\" $OpenBSD: strsep.3,v 1.8 2000/04/21 15:24:20 aaron Exp $
+.\" $OpenBSD: strsep.3,v 1.9 2001/06/14 20:38:38 aaron Exp $
.\"
.\" Copyright (c) 1990, 1991, 1993
.\" The Regents of the University of California. All rights reserved.
@@ -90,9 +90,12 @@ argument vector:
.Bd -literal -offset indent
char **ap, *argv[10], *inputstring;
-for (ap = argv; (*ap = strsep(&inputstring, " \et")) != NULL;)
+for (ap = argv; ap < &argv[9] &&
+ (*ap = strsep(&inputstring, " \et")) != NULL;) {
if (**ap != '\e0')
- ++ap;
+ ap++;
+}
+*ap = NULL;
.Ed
.Sh HISTORY
The