X-Git-Url: http://www.privoxy.org/gitweb/?p=privoxy.git;a=blobdiff_plain;f=pcrs.c;h=89bab8fa9794531d1524cd1b8b2412331f0e69cc;hp=1ad3448a605cb7d6ecc02555a0485335df8f65cf;hb=1be5c48e561329dfecddebf0f27f9ccc47bce3cf;hpb=7043fa1105a7fa5f7dbcf9824971f47fd88d3b71 diff --git a/pcrs.c b/pcrs.c index 1ad3448a..89bab8fa 100644 --- a/pcrs.c +++ b/pcrs.c @@ -1,4 +1,4 @@ -const char pcrs_rcs[] = "$Id: pcrs.c,v 1.2 2001/05/22 18:46:04 oes Exp $"; +const char pcrs_rcs[] = "$Id: pcrs.c,v 1.4 2001/05/25 14:12:40 oes Exp $"; /********************************************************************* * @@ -43,6 +43,12 @@ const char pcrs_rcs[] = "$Id: pcrs.c,v 1.2 2001/05/22 18:46:04 oes Exp $"; * * Revisions : * $Log: pcrs.c,v $ + * Revision 1.4 2001/05/25 14:12:40 oes + * Fixed bug: Empty substitutes now detected + * + * Revision 1.3 2001/05/25 11:03:55 oes + * Added sanity check for NULL jobs to pcrs_exec_substitution + * * Revision 1.2 2001/05/22 18:46:04 oes * * - Enabled filtering banners by size rather than URL @@ -173,7 +179,8 @@ int my_strsep(char *token, char **text, char delimiter, char quote_char) *********************************************************************/ int pcrs_compile_perl_options(char *optstring, int *globalflag) { - int i, rc = 0; + size_t i; + int rc = 0; *globalflag = 0; for (i=0; i < strlen(optstring); i++) { @@ -387,7 +394,7 @@ pcrs_job *pcrs_make_job(char *command, int *errptr) { switch (i) { - /* We don't care about the command and assume 's' */ + /* We don't care about the command and assume 's' */ case 0: break; @@ -398,13 +405,15 @@ pcrs_job *pcrs_make_job(char *command, int *errptr) /* The substitute */ case 2: - newjob->substitute = pcrs_compile_replacement(token, errptr); - if (newjob->substitute == NULL) + if ((newjob->substitute = pcrs_compile_replacement(token, errptr)) == NULL) { pcrs_free_job(newjob); return NULL; } - break; + else + { + break; + } /* The options */ case 3: @@ -422,6 +431,14 @@ pcrs_job *pcrs_make_job(char *command, int *errptr) } free(token); + /* We have a valid substitute? */ + if (newjob->substitute == NULL) + { + *errptr = PCRS_ERR_CMDSYNTAX; + pcrs_free_job(newjob); + return NULL; + } + /* Compile the pattern */ newjob->pattern = pcre_compile(dummy, newjob->options, &error, errptr, NULL); if (newjob->pattern == NULL)