summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog3
-rw-r--r--pcregrep.c8
2 files changed, 8 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog
index cac3973..019e0f5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -20,6 +20,9 @@ several lines after the start.
4. A (?# style comment is now ignored between a basic quantifier and a
following '+' or '?' (example: /X+(?#comment)?Y/.
+5. Avoid use of a potentially overflowing buffer in pcregrep (patch by Petr
+Pisar).
+
Version 8.40 11-January-2017
----------------------------
diff --git a/pcregrep.c b/pcregrep.c
index 3cd70ee..87a3c2e 100644
--- a/pcregrep.c
+++ b/pcregrep.c
@@ -3190,9 +3190,11 @@ for (j = 1, cp = patterns; cp != NULL; j++, cp = cp->next)
cp->hint = pcre_study(cp->compiled, study_options, &error);
if (error != NULL)
{
- char s[16];
- if (patterns->next == NULL) s[0] = 0; else sprintf(s, " number %d", j);
- fprintf(stderr, "pcregrep: Error while studying regex%s: %s\n", s, error);
+ if (patterns->next == NULL)
+ fprintf(stderr, "pcregrep: Error while studying regex: %s\n", error);
+ else
+ fprintf(stderr, "pcregrep: Error while studying regex number %d: %s\n",
+ j, error);
goto EXIT2;
}
#ifdef SUPPORT_PCREGREP_JIT