diff options
author | Paul Eggert <eggert@cs.ucla.edu> | 2012-02-29 00:47:56 -0800 |
---|---|---|
committer | Paul Eggert <eggert@cs.ucla.edu> | 2012-03-01 07:46:03 -0800 |
commit | 4572ea4649d025e51463d48c2d06a1c66134cdb8 (patch) | |
tree | e91daafefb35945f7c39cf07fc845e401f045ab6 /src | |
parent | a19dc139056aaf09137991bacef364c8fef60168 (diff) | |
download | grep-4572ea4649d025e51463d48c2d06a1c66134cdb8.tar.gz |
grep: avoid mishandling of long lines
* src/pcresearch.c (Pexecute): Do not pass a line longer than
INT_MAX to pcre_exec, since its API does not permit that.
Diffstat (limited to 'src')
-rw-r--r-- | src/pcresearch.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/src/pcresearch.c b/src/pcresearch.c index 2eda5f1a..2994e653 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); |