Changeset 588 for trunk/src/sh_log_correlate.c
- Timestamp:
- Oct 26, 2025, 12:17:47 PM (16 hours ago)
- File:
-
- 1 edited
-
trunk/src/sh_log_correlate.c (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/sh_log_correlate.c
r481 r588 9 9 #include <time.h> 10 10 11 /* Debian/Ubuntu: libpcre3-dev */ 12 #ifdef HAVE_PCRE_PCRE_H 13 #include <pcre/pcre.h> 11 /* Debian/Ubuntu: libpcre2-dev */ 12 #define PCRE2_CODE_UNIT_WIDTH 8 13 #ifdef HAVE_PCRE2_PCRE2_H 14 #include <pcre2/pcre2.h> 14 15 #else 15 #include <pcre .h>16 #include <pcre2.h> 16 17 #endif 17 18 18 #ifndef PCRE_NO_AUTO_CAPTURE19 #define PCRE_NO_AUTO_CAPTURE 020 #endif21 19 22 20 #include "samhain.h" … … 173 171 { 174 172 sh_string * label; /* label of match rule */ 175 pcre * rule; /* compiled regex for rule */173 pcre2_code * rule; /* compiled regex for rule */ 176 174 time_t reported; /* last reported */ 177 175 struct sh_qeval * queue; /* assigned queue */ … … 208 206 { 209 207 struct sh_mkeep * mkeep = SH_ALLOC(sizeof(struct sh_mkeep)); 210 const char *error;211 interroffset;208 int error; 209 size_t erroffset; 212 210 struct sh_qeval * rqueue = NULL; 213 211 214 mkeep->rule = pcre _compile(pattern, PCRE_NO_AUTO_CAPTURE,215 &error, &erroffset, NULL);212 mkeep->rule = pcre2_compile((PCRE2_SPTR8)pattern, PCRE2_ZERO_TERMINATED, PCRE2_NO_AUTO_CAPTURE, 213 &error, &erroffset, NULL); 216 214 if (!(mkeep->rule)) 217 215 { … … 239 237 if (!rqueue) 240 238 { 241 pcre _free(mkeep->rule);239 pcre2_code_free(mkeep->rule); 242 240 SH_FREE(splits); 243 241 SH_FREE(mkeep); … … 264 262 mkeep_list = mkeep->next; 265 263 sh_string_destroy(&(mkeep->label)); 266 pcre _free(mkeep->rule);264 pcre2_code_free(mkeep->rule); 267 265 mkeep = mkeep_list; 268 266 } … … 286 284 while (mkeep) 287 285 { 288 /* Use pcre_dfa_exec() to obtain number of matches. Needs ovector 289 * array, otherwise number of matches is not returned. 290 */ 291 #if defined(HAVE_PCRE_DFA_EXEC) 292 int ovector[SH_MINIBUF]; 293 int wspace[SH_MINIBUF]; 294 #endif 295 296 #if defined(HAVE_PCRE_DFA_EXEC) 297 int val = pcre_dfa_exec(mkeep->rule, NULL, 298 sh_string_str(res), 299 (int)sh_string_len(res), 300 0, /* start at offset 0 in the subject */ 301 0, 302 ovector, SH_MINIBUF, 303 wspace, SH_MINIBUF); 304 #else 305 int val = pcre_exec(mkeep->rule, NULL, 306 sh_string_str(res), 307 (int)sh_string_len(res), 308 0, /* start at offset 0 in the subject */ 309 0, 310 NULL, 0); 311 val = (val >= 0) ? 1 : val; 312 #endif 313 314 if (val >= 0) 286 pcre2_match_data * match_data = pcre2_match_data_create_from_pattern(mkeep->rule, NULL); 287 288 int val = pcre2_match(mkeep->rule, 289 (PCRE2_SPTR8) sh_string_str(res), (int)sh_string_len(res), 0, 290 0, match_data, NULL); 291 292 pcre2_match_data_free(match_data); 293 294 if (val > 0) 315 295 { 316 296 sh_string * alias;
Note:
See TracChangeset
for help on using the changeset viewer.