dcavalca / rpms / util-linux

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