summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormmcc <mmcc@openbsd.org>2015-12-07 18:50:06 +0000
committermmcc <mmcc@openbsd.org>2015-12-07 18:50:06 +0000
commit6f917606a47730fd5c395ccc54375d2200d4a878 (patch)
tree2674e37d3fd57cda91eb9eba0b0d80f7d64d6136
parenttweak the code a bit and add a -w option to display day of week. (diff)
downloadwireguard-openbsd-6f917606a47730fd5c395ccc54375d2200d4a878.tar.xz
wireguard-openbsd-6f917606a47730fd5c395ccc54375d2200d4a878.zip
Represent line numbers with off_t rather than int. This prevents
overflow on huge inputs. ok millert@, deraadt@
-rw-r--r--usr.bin/grep/grep.h4
-rw-r--r--usr.bin/grep/util.c4
2 files changed, 4 insertions, 4 deletions
diff --git a/usr.bin/grep/grep.h b/usr.bin/grep/grep.h
index 05a251e5028..71379a8ca8b 100644
--- a/usr.bin/grep/grep.h
+++ b/usr.bin/grep/grep.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: grep.h,v 1.22 2015/03/16 13:26:52 millert Exp $ */
+/* $OpenBSD: grep.h,v 1.23 2015/12/07 18:50:06 mmcc Exp $ */
/*-
* Copyright (c) 1999 James Howard and Dag-Erling Coïdan Smørgrav
@@ -43,7 +43,7 @@
typedef struct {
size_t len;
- int line_no;
+ off_t line_no;
off_t off;
char *file;
char *dat;
diff --git a/usr.bin/grep/util.c b/usr.bin/grep/util.c
index 39afe182dd4..d5bbed7df1e 100644
--- a/usr.bin/grep/util.c
+++ b/usr.bin/grep/util.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: util.c,v 1.50 2015/06/25 02:04:08 uebayasi Exp $ */
+/* $OpenBSD: util.c,v 1.51 2015/12/07 18:50:06 mmcc Exp $ */
/*-
* Copyright (c) 1999 James Howard and Dag-Erling Coïdan Smørgrav
@@ -623,7 +623,7 @@ printline(str_t *line, int sep, regmatch_t *pmatch)
if (nflag) {
if (n)
putchar(sep);
- printf("%d", line->line_no);
+ printf("%lld", (long long)line->line_no);
++n;
}
if (bflag) {