bug-grep
[Top][All Lists]
Advanced

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

[PATCH 4/5] grep: avoid mishandling of long lines


From: Paul Eggert
Subject: [PATCH 4/5] grep: avoid mishandling of long lines
Date: Thu, 01 Mar 2012 12:50:05 -0800
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:10.0.1) Gecko/20120209 Thunderbird/10.0.1

* src/pcresearch.c (Pexecute): Do not pass a line longer than
INT_MAX to pcre_exec, since its API does not permit that.
---
 src/pcresearch.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/src/pcresearch.c b/src/pcresearch.c
index 2eda5f1..2994e65 100644
--- a/src/pcresearch.c
+++ b/src/pcresearch.c
@@ -134,6 +134,9 @@ Pexecute (char const *buf, size_t size, size_t *match_size,
       if (start_ptr && start_ptr >= line_end)
         continue;
 
+      if (INT_MAX < line_end - line_buf)
+        error (EXIT_TROUBLE, 0, _("exceeded PCRE's line length limit"));
+
       e = pcre_exec (cre, extra, line_buf, line_end - line_buf,
                      start_ofs < 0 ? 0 : start_ofs, 0,
                      sub, sizeof sub / sizeof *sub);
-- 
1.7.6.5



reply via email to

[Prev in Thread] Current Thread [Next in Thread]