summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorRay Lai <ray@cvs.openbsd.org>2006-11-16 00:16:30 +0000
committerRay Lai <ray@cvs.openbsd.org>2006-11-16 00:16:30 +0000
commit642232c91868e500c7026088d01fee55bfa48b0a (patch)
tree5aad170258df3ac339e06489249a123cb279c3c8 /usr.bin
parent92f8eae34fb3c6dd9dfd43515f7f8de4f9be5a80 (diff)
Fix undefined behavior (var = --var).
From Alexey Dobriyan <adobriyan at gmail dot com>. OK moritz@ and jaredy@.
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/mail/fio.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/usr.bin/mail/fio.c b/usr.bin/mail/fio.c
index 6aaed2d0bb5..57ee7046244 100644
--- a/usr.bin/mail/fio.c
+++ b/usr.bin/mail/fio.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: fio.c,v 1.26 2006/04/02 00:51:37 deraadt Exp $ */
+/* $OpenBSD: fio.c,v 1.27 2006/11/16 00:16:29 ray Exp $ */
/* $NetBSD: fio.c,v 1.8 1997/07/07 22:57:55 phil Exp $ */
/*
@@ -34,7 +34,7 @@
#if 0
static const char sccsid[] = "@(#)fio.c 8.2 (Berkeley) 4/20/95";
#else
-static const char rcsid[] = "$OpenBSD: fio.c,v 1.26 2006/04/02 00:51:37 deraadt Exp $";
+static const char rcsid[] = "$OpenBSD: fio.c,v 1.27 2006/11/16 00:16:29 ray Exp $";
#endif
#endif /* not lint */
@@ -123,8 +123,11 @@ setptr(FILE *ibuf, off_t offset)
* that reside on a DOS partition.
*/
if (count >= 2 && linebuf[count-1] == '\n' &&
- linebuf[count - 2] == '\r')
- linebuf[count - 2] = linebuf[--count];
+ linebuf[count - 2] == '\r') {
+ linebuf[count - 2] = '\n';
+ linebuf[count - 1] = '\0';
+ count--;
+ }
(void)fwrite(linebuf, sizeof(*linebuf), count, otf);
if (ferror(otf))