git://git.exim.org
/
exim.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Use pool storage for regex operations
[exim.git]
/
src
/
src
/
regex.c
diff --git
a/src/src/regex.c
b/src/src/regex.c
index a3d6659a6428e1003bd2ef93ca900ccb9f4f93e2..9b7b07405a78c1b3ac7f1436906026884f0b44ac 100644
(file)
--- a/
src/src/regex.c
+++ b/
src/src/regex.c
@@
-2,9
+2,10
@@
* Exim - an Internet mail transport agent *
*************************************************/
* Exim - an Internet mail transport agent *
*************************************************/
-/* Copyright (c) Tom Kistner <tom@duncanthrax.net> 2003-2015
+/*
+ * Copyright (c) The Exim Maintainers 2016 - 2022
+ * Copyright (c) Tom Kistner <tom@duncanthrax.net> 2003-2015
* License: GPL
* License: GPL
- * Copyright (c) The Exim Maintainers 2016 - 2018
*/
/* Code for matching regular expressions against headers and body.
*/
/* Code for matching regular expressions against headers and body.
@@
-45,7
+46,7
@@
while ((regex_string = string_nextinlist(&list, &sep, NULL, 0)))
/* compile our regular expression */
if (!(re = pcre2_compile( (PCRE2_SPTR) regex_string, PCRE2_ZERO_TERMINATED,
/* compile our regular expression */
if (!(re = pcre2_compile( (PCRE2_SPTR) regex_string, PCRE2_ZERO_TERMINATED,
- 0, &err, &pcre_erroffset, pcre_cmp_ctx)))
+ 0, &err, &pcre_erroffset, pcre_
gen_
cmp_ctx)))
{
uschar errbuf[128];
pcre2_get_error_message(err, errbuf, sizeof(errbuf));
{
uschar errbuf[128];
pcre2_get_error_message(err, errbuf, sizeof(errbuf));
@@
-55,7
+56,7
@@
while ((regex_string = string_nextinlist(&list, &sep, NULL, 0)))
continue;
}
continue;
}
- ri = store_get(sizeof(pcre_list),
FALSE
);
+ ri = store_get(sizeof(pcre_list),
GET_UNTAINTED
);
ri->re = re;
ri->pcre_text = regex_string;
ri->next = re_list_head;
ri->re = re;
ri->pcre_text = regex_string;
ri->next = re_list_head;
@@
-74,7
+75,7
@@
for (pcre_list * ri = re_list_head; ri; ri = ri->next)
int n;
/* try matcher on the line */
int n;
/* try matcher on the line */
- if ((n = pcre2_match(ri->re, (PCRE2_SPTR)linebuffer, len, 0, 0, md, pcre_mtc_ctx)) > 0)
+ if ((n = pcre2_match(ri->re, (PCRE2_SPTR)linebuffer, len, 0, 0, md, pcre_
gen_
mtc_ctx)) > 0)
{
Ustrncpy(regex_match_string_buffer, ri->pcre_text,
sizeof(regex_match_string_buffer)-1);
{
Ustrncpy(regex_match_string_buffer, ri->pcre_text,
sizeof(regex_match_string_buffer)-1);
@@
-84,14
+85,14
@@
for (pcre_list * ri = re_list_head; ri; ri = ri->next)
{
PCRE2_UCHAR * cstr;
PCRE2_SIZE cslen;
{
PCRE2_UCHAR * cstr;
PCRE2_SIZE cslen;
- pcre2_substring_get_bynumber(md, nn, &cstr, &cslen);
+ pcre2_substring_get_bynumber(md, nn, &cstr, &cslen);
/* uses same ctx as md */
regex_vars[nn-1] = CUS cstr;
}
return OK;
}
}
regex_vars[nn-1] = CUS cstr;
}
return OK;
}
}
-pcre2_match_data_free(md);
+/* pcre2_match_data_free(md); gen ctx needs no free */
return FAIL;
}
return FAIL;
}
@@
-133,7
+134,7
@@
if (!(re_list_head = compile(*listptr)))
return FAIL; /* no regexes -> nothing to do */
/* match each line against all regexes */
return FAIL; /* no regexes -> nothing to do */
/* match each line against all regexes */
-linebuffer = store_get(32767,
TRUE); /* tainted */
+linebuffer = store_get(32767,
GET_TAINTED);
while (fgets(CS linebuffer, 32767, mbox_file))
{
if ( mime_stream && mime_current_boundary /* check boundary */
while (fgets(CS linebuffer, 32767, mbox_file))
{
if ( mime_stream && mime_current_boundary /* check boundary */
@@
-204,7
+205,7
@@
if (!(f = fopen(CS mime_decoded_filename, "rb")))
}
/* get 32k memory, tainted */
}
/* get 32k memory, tainted */
-mime_subject = store_get(32767,
TRUE
);
+mime_subject = store_get(32767,
GET_TAINTED
);
mime_subject_len = fread(mime_subject, 1, 32766, f);
mime_subject_len = fread(mime_subject, 1, 32766, f);