diff options
author | Hakan Olsson <ho@cvs.openbsd.org> | 2002-08-08 10:37:42 +0000 |
---|---|---|
committer | Hakan Olsson <ho@cvs.openbsd.org> | 2002-08-08 10:37:42 +0000 |
commit | e2c5669a1c3d84b55c4fe930ce952c5ef94a0e8c (patch) | |
tree | 75b368dd472fd0952f0d4e0d3a67cd348a74ebeb /usr.bin | |
parent | 9d643ec9f55e642bf8873b71559368b2d6df1ecc (diff) |
3rd arg for open, plus some bounds checking. miod@ ok.
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/msgs/msgs.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/usr.bin/msgs/msgs.c b/usr.bin/msgs/msgs.c index 9e5a3c0ebda..1d3f25d4eaf 100644 --- a/usr.bin/msgs/msgs.c +++ b/usr.bin/msgs/msgs.c @@ -1,4 +1,4 @@ -/* $OpenBSD: msgs.c,v 1.21 2002/02/16 21:27:49 millert Exp $ */ +/* $OpenBSD: msgs.c,v 1.22 2002/08/08 10:37:41 ho Exp $ */ /* $NetBSD: msgs.c,v 1.7 1995/09/28 06:57:40 tls Exp $ */ /*- @@ -44,7 +44,7 @@ static char copyright[] = #if 0 static char sccsid[] = "@(#)msgs.c 8.2 (Berkeley) 4/28/95"; #else -static char rcsid[] = "$OpenBSD: msgs.c,v 1.21 2002/02/16 21:27:49 millert Exp $"; +static char rcsid[] = "$OpenBSD: msgs.c,v 1.22 2002/08/08 10:37:41 ho Exp $"; #endif #endif /* not lint */ @@ -793,14 +793,16 @@ ask(prompt) if (inch == 's') { in = nxtfld(inbuf); if (*in) { - for (n=0; in[n] > ' '; n++) { /* sizeof fname? */ + for (n=0; + in[n] > ' ' && n < sizeof *fname - 1; + n++) { fname[n] = in[n]; } fname[n] = NULL; } else strcpy(fname, "Messages"); - fd = open(fname, O_RDWR|O_EXCL|O_CREAT|O_APPEND); + fd = open(fname, O_RDWR|O_EXCL|O_CREAT|O_APPEND, 0666); } else { strcpy(fname, _PATH_TMPFILE); |