All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] more: fix repeat search crash
@ 2015-01-27 22:28 Sami Kerola
  2015-01-28  7:28 ` Karel Zak
  0 siblings, 1 reply; 2+ messages in thread
From: Sami Kerola @ 2015-01-27 22:28 UTC (permalink / raw)
  To: util-linux; +Cc: Sami Kerola

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>
---
 text-utils/more.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/text-utils/more.c b/text-utils/more.c
index 74148a7..94b0455 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"));
 	}
 }
-- 
2.2.2


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] more: fix repeat search crash
  2015-01-27 22:28 [PATCH] more: fix repeat search crash Sami Kerola
@ 2015-01-28  7:28 ` Karel Zak
  0 siblings, 0 replies; 2+ messages in thread
From: Karel Zak @ 2015-01-28  7:28 UTC (permalink / raw)
  To: Sami Kerola; +Cc: util-linux

On Tue, Jan 27, 2015 at 10:28:57PM +0000, Sami Kerola wrote:
>  text-utils/more.c | 3 +++
>  1 file changed, 3 insertions(+)

 Applied, thanks.

-- 
 Karel Zak  <kzak@redhat.com>
 http://karelzak.blogspot.com

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-01-28 20:58 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-01-27 22:28 [PATCH] more: fix repeat search crash Sami Kerola
2015-01-28  7:28 ` Karel Zak

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.