cdown / rpms / util-linux

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