X-Git-Url: http://www.privoxy.org/gitweb/?p=privoxy.git;a=blobdiff_plain;f=pcrs.c;h=93f582784611efb612ab3bec1f90aba15c1d0a87;hp=4d112271a08a71f63d622f0ad72c8d684fccf21d;hb=dead25538ae04c753b79146fcd69d6fa2d1ef8b9;hpb=37b60a3260c885bfa3f33d94a186a2741fca52f5 diff --git a/pcrs.c b/pcrs.c index 4d112271..93f58278 100644 --- a/pcrs.c +++ b/pcrs.c @@ -1,4 +1,4 @@ -const char pcrs_rcs[] = "$Id: pcrs.c,v 1.46 2014/11/14 10:40:10 fabiankeil Exp $"; +const char pcrs_rcs[] = "$Id: pcrs.c,v 1.48 2015/12/27 12:45:46 fabiankeil Exp $"; /********************************************************************* * * File : $Source: /cvsroot/ijbswa/current/pcrs.c,v $ @@ -80,6 +80,8 @@ static int is_hex_sequence(const char *sequence); *********************************************************************/ const char *pcrs_strerror(const int error) { + static char buf[100]; + if (error != 0) { switch (error) @@ -119,7 +121,11 @@ const char *pcrs_strerror(const int error) * version. If Privoxy is linked against a newer * PCRE version all bets are off ... */ - default: return "Unknown error. Privoxy out of sync with PCRE?"; + default: + snprintf(buf, sizeof(buf), + "Error code %d. For details, check the pcre documentation.", + error); + return buf; } } /* error >= 0: No error */ @@ -370,7 +376,9 @@ static pcrs_substitute *pcrs_compile_replacement(const char *replacement, int tr } /* Valid and in range? -> record */ - if (0 <= r->backref[l] && r->backref[l] < PCRS_MAX_SUBMATCHES + 2) + if ((0 <= r->backref[l]) && + (r->backref[l] < PCRS_MAX_SUBMATCHES + 2) && + (l < PCRS_MAX_SUBMATCHES - 1)) { r->backref_count[r->backref[l]] += 1; r->block_offset[++l] = k;