|
|
05ad79 |
From d7e6a773863ad47dbdab9244b6629590d4b46f0e Mon Sep 17 00:00:00 2001
|
|
|
05ad79 |
From: Sami Kerola <kerolasa@iki.fi>
|
|
|
05ad79 |
Date: Tue, 27 Jan 2015 22:28:57 +0000
|
|
|
05ad79 |
Subject: [PATCH 100/116] more: fix repeat search crash
|
|
|
05ad79 |
|
|
|
05ad79 |
Repeating a search for a pattern that did not found made more(1) to
|
|
|
05ad79 |
crash. To reproduce 'more /etc/services' and search for 'doom'; you will
|
|
|
05ad79 |
find a service in port 666 - pressing '.' after that result used to cause
|
|
|
05ad79 |
core dump.
|
|
|
05ad79 |
|
|
|
05ad79 |
Upstream: https://github.com/karelzak/util-linux/commit/bc1ed338814f69473629b04c5e9efae5d7db3b72
|
|
|
05ad79 |
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1403973
|
|
|
05ad79 |
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
|
|
|
05ad79 |
---
|
|
|
05ad79 |
text-utils/more.c | 3 +++
|
|
|
05ad79 |
1 file changed, 3 insertions(+)
|
|
|
05ad79 |
|
|
|
05ad79 |
diff --git a/text-utils/more.c b/text-utils/more.c
|
|
|
05ad79 |
index 496b116..0e9c2bd 100644
|
|
|
05ad79 |
--- a/text-utils/more.c
|
|
|
05ad79 |
+++ b/text-utils/more.c
|
|
|
05ad79 |
@@ -1588,6 +1588,8 @@ void search(char buf[], FILE *file, register int n)
|
|
|
05ad79 |
context.line = saveln = Currline;
|
|
|
05ad79 |
context.chrctr = startline;
|
|
|
05ad79 |
lncount = 0;
|
|
|
05ad79 |
+ if (!buf)
|
|
|
05ad79 |
+ goto notfound;
|
|
|
05ad79 |
if ((rc = regcomp(&re, buf, REG_NOSUB)) != 0) {
|
|
|
05ad79 |
char s[REGERR_BUF];
|
|
|
05ad79 |
regerror(rc, &re, s, sizeof s);
|
|
|
05ad79 |
@@ -1644,6 +1646,7 @@ void search(char buf[], FILE *file, register int n)
|
|
|
05ad79 |
}
|
|
|
05ad79 |
free(previousre);
|
|
|
05ad79 |
previousre = NULL;
|
|
|
05ad79 |
+notfound:
|
|
|
05ad79 |
more_error(_("Pattern not found"));
|
|
|
05ad79 |
}
|
|
|
05ad79 |
}
|
|
|
05ad79 |
--
|
|
|
05ad79 |
2.9.3
|
|
|
05ad79 |
|