summaryrefslogtreecommitdiffstats
path: root/usr.bin/indent
diff options
context:
space:
mode:
authormillert <millert@openbsd.org>2005-05-15 03:27:04 +0000
committermillert <millert@openbsd.org>2005-05-15 03:27:04 +0000
commit80a2daadd61611f3e43dda2e8b15cedfa274eadc (patch)
treed587eac5b33892fbff5371d681d33eb6b06ebcb7 /usr.bin/indent
parentMake usage/SYNOPSIS saner and sort the options. With jmc@ (diff)
downloadwireguard-openbsd-80a2daadd61611f3e43dda2e8b15cedfa274eadc.tar.xz
wireguard-openbsd-80a2daadd61611f3e43dda2e8b15cedfa274eadc.zip
When checking for comment characters using negative pointer arithmetic
make sure that we don't peek at memory outside the string boundaries. Fixes a core dump with mmap malloc.
Diffstat (limited to 'usr.bin/indent')
-rw-r--r--usr.bin/indent/io.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/usr.bin/indent/io.c b/usr.bin/indent/io.c
index b0a012802d1..cea03237ccb 100644
--- a/usr.bin/indent/io.c
+++ b/usr.bin/indent/io.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: io.c,v 1.9 2004/07/20 03:50:26 deraadt Exp $ */
+/* $OpenBSD: io.c,v 1.10 2005/05/15 03:27:04 millert Exp $ */
/*
* Copyright (c) 1985 Sun Microsystems, Inc.
@@ -33,7 +33,7 @@
#ifndef lint
/*static char sccsid[] = "@(#)io.c 8.1 (Berkeley) 6/6/93";*/
-static char rcsid[] = "$OpenBSD: io.c,v 1.9 2004/07/20 03:50:26 deraadt Exp $";
+static char rcsid[] = "$OpenBSD: io.c,v 1.10 2005/05/15 03:27:04 millert Exp $";
#endif /* not lint */
#include <stdio.h>
@@ -372,7 +372,7 @@ fill_buffer(void)
}
buf_ptr = in_buffer;
buf_end = p;
- if (p[-2] == '/' && p[-3] == '*') {
+ if (p - 3 >= in_buffer && p[-2] == '/' && p[-3] == '*') {
if (in_buffer[3] == 'I' && strncmp(in_buffer, "/**INDENT**", 11) == 0)
fill_buffer(); /* flush indent error message */
else {