Bug#999956: snort: depends on obsolete pcre3 library (2/2)
From
Yavor Doganov@21:1/5 to
All on Tue Jan 2 15:40:02 2024
[continued from previous message]
- ((ScPcreMatchLimitNewConf(sc) != -1) || (ScPcreMatchLimitRecursionNewConf(sc) != -1)))
- {
- extra_extra = (pcre_extra *)SnortAlloc(sizeof(pcre_extra));
- if (ScPcreMatchLimitNewConf(sc) != -1)
- {
- extra_extra->flags |= PCRE_EXTRA_MATCH_LIMIT;
- extra_extra->match_limit = ScPcreMatchLimitNewConf(sc);
- }
+ if ((ScPcreMatchLimitNewConf(sc) != -1) && !(snort_options & SNORT_PCRE_OVERRIDE_MATCH_LIMIT))
+ pcre2_set_match_limit(ctxt, ScPcreMatchLimitNewConf(sc));
-#ifdef PCRE_EXTRA_MATCH_LIMIT_RECURSION
- if (ScPcreMatchLimitRecursionNewConf(sc) != -1)
- {
- extra_extra->flags |= PCRE_EXTRA_MATCH_LIMIT_RECURSION;
- extra_extra->match_limit_recursion = ScPcreMatchLimitRecursionNewConf(sc);
- }
-#endif
- }
- }
+ if ((ScPcreMatchLimitRecursionNewConf(sc) != -1) && !(snort_options & SNORT_PCRE_OVERRIDE_MATCH_LIMIT))
+ pcre2_set_depth_limit(ctxt, ScPcreMatchLimitRecursionNewConf(sc));
- return extra_extra;
+ return ctxt;
}
/* pcreOvectorInfo
*
* Get the Ovector configuration for PCRE from the snort.conf
*/
-void pcreOvectorInfo(int **ovector, int *ovector_size)
+void pcreOvectorInfo(PCRE2_SIZE **ovector, int *ovector_size)
{
*ovector = snort_conf->pcre_ovector;
*ovector_size = snort_conf->pcre_ovector_size;
}
int pcreExec(const void *code, const void *extra, const char *subj,
- int len, int start, int options, int *ovec, int ovecsize)
+ int len, int start, int options, PCRE2_SIZE *ovec, int ovecsize)
{
- return pcre_exec((const pcre *)code, (const pcre_extra *)extra, subj, len, start, options, ovec, ovecsize);
+ pcre2_match_data *md;
+ int rc;
+
+ md = pcre2_match_data_create(ovecsize, NULL);
+ rc = pcre2_match((pcre2_code *)code, (PCRE2_SPTR)subj, len, start, options, md, (pcre2_match_context *)extra);
+ ovec = pcre2_get_ovector_pointer(md);
+ pcre2_match_data_free(md);
+ return rc;
}
static int setFlowId(const void* p, uint32_t id)
--- snort-2.9.15.1.orig/src/dynamic-plugins/sf_convert_dynamic.c
+++ snort-2.9.15.1/src/dynamic-plugins/sf_convert_dynamic.c
@@ -52,9 +52,9 @@
extern void ParsePattern(char *, OptTreeNode *, int);
extern void ParseProtectedPattern(char *, OptTreeNode *, int);
-extern void *pcreCompile(const char *pattern, int options, const char **errptr,
- int *erroffset, const unsigned char *tableptr);
-extern void *pcreStudy(struct _SnortConfig *sc, const void *code, int options, const char **errptr);
+extern void *pcreCompile(const char *pattern, uint32_t options, int *errptr,
+ PCRE2_SIZE *erroffset);
+extern void *pcreStudy(struct _SnortConfig *sc, int options);
extern int SnortPcre(void *option_data, Packet *p);
extern int FlowBitsCheck(void *option_data, Packet *p);
@@ -520,8 +520,8 @@
PCREInfo *pcre_info = rule->options[index]->option_u.pcre;
OptFpList *fpl;
void *pcre_dup;
- const char *error;
- int erroroffset;
+ int error;
+ PCRE2_SIZE erroroffset;