summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Stormont <astormont@racktopsystems.com>2018-05-24 13:55:23 +0100
committerRobert Mustacchi <rm@joyent.com>2018-06-01 18:03:01 +0000
commitd9241f995480d9097812b34500484c0fff9d7528 (patch)
tree5101e0046d26b6aa03828f70c6441822ba517122
parentfe12dc752b42da16028a16f4226e5295506fdb28 (diff)
downloadillumos-joyent-d9241f995480d9097812b34500484c0fff9d7528.tar.gz
9552 grep segfaults when you ask for context
Reviewed by: Yuri Pankov <yuripv@yuripv.net> Reviewed by: Toomas Soome <tsoome@me.com> Reviewed by: Andy Fiddaman <af@citrus-it.net> Approved by: Robert Mustacchi <rm@joyent.com>
-rw-r--r--usr/src/cmd/grep/grep.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/usr/src/cmd/grep/grep.c b/usr/src/cmd/grep/grep.c
index eabd465cca..7054d1f602 100644
--- a/usr/src/cmd/grep/grep.c
+++ b/usr/src/cmd/grep/grep.c
@@ -35,6 +35,7 @@
*/
/*
+ * Copyright 2018 RackTop Systems.
* Copyright 2018 Nexenta Systems, Inc.
* Copyright 2013 Damian Bogel. All rights reserved.
*/
@@ -1277,8 +1278,8 @@ L_start_process:
goto L_next_line;
/* Do we have room to add this line to the context buffer? */
- if ((line_len + 1) > (conbuflen -
- (conptrend >= conptr) ? conptrend - conbuf : 0)) {
+ while ((line_len + 1) > (conbuflen -
+ ((conptrend >= conptr) ? conptrend - conbuf : 0))) {
char *oldconbuf = conbuf;
char *oldconptr = conptr;
long tmp = matchptr - conptr;