[PATCH] more: fix repeat search crash

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxx>
---
 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

--
To unsubscribe from this list: send the line "unsubscribe util-linux" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux