summaryrefslogtreecommitdiffstats
path: root/text-utils/more.c
diff options
context:
space:
mode:
authorSami Kerola2015-01-27 23:28:57 +0100
committerKarel Zak2015-01-28 08:27:45 +0100
commitbc1ed338814f69473629b04c5e9efae5d7db3b72 (patch)
treea97c6a36630031ea0cd998c3cdeb2178be15e29c /text-utils/more.c
parentsetarch: fix --list (diff)
downloadkernel-qcow2-util-linux-bc1ed338814f69473629b04c5e9efae5d7db3b72.tar.gz
kernel-qcow2-util-linux-bc1ed338814f69473629b04c5e9efae5d7db3b72.tar.xz
kernel-qcow2-util-linux-bc1ed338814f69473629b04c5e9efae5d7db3b72.zip
more: fix repeat search crash
Repeating a search for a pattern that did not found made more(1) to crash. To reproduce 'more /etc/services' and search for 'doom'; you will find a service in port 666 - pressing '.' after that result used to cause core dump. Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Diffstat (limited to 'text-utils/more.c')
-rw-r--r--text-utils/more.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/text-utils/more.c b/text-utils/more.c
index 74148a7ab..94b045506 100644
--- a/text-utils/more.c
+++ b/text-utils/more.c
@@ -1605,6 +1605,8 @@ void search(char buf[], FILE *file, register int n)
context.line = saveln = Currline;
context.chrctr = startline;
lncount = 0;
+ if (!buf)
+ goto notfound;
if ((rc = regcomp(&re, buf, REG_NOSUB)) != 0) {
char s[REGERR_BUF];
regerror(rc, &re, s, sizeof s);
@@ -1661,6 +1663,7 @@ void search(char buf[], FILE *file, register int n)
}
free(previousre);
previousre = NULL;
+notfound:
more_error(_("Pattern not found"));
}
}