diff --git a/src/n2n_regex.c b/src/n2n_regex.c index dd20ffd..a88ec39 100644 --- a/src/n2n_regex.c +++ b/src/n2n_regex.c @@ -248,8 +248,9 @@ re_t re_compile(const char* pattern) } /* 'UNUSED' is a sentinel used to indicate end-of-pattern */ re_compiled[j].type = UNUSED; - - return (re_t) re_compiled; + re_t re_p = (re_t)calloc(1, sizeof(re_compiled)); + memcpy (re_p, re_compiled, sizeof(re_compiled)); + return (re_t) re_p; } void re_print(regex_t* pattern) diff --git a/src/sn_utils.c b/src/sn_utils.c index c20a6dc..1f7a743 100644 --- a/src/sn_utils.c +++ b/src/sn_utils.c @@ -817,7 +817,7 @@ static int process_udp(n2n_sn_t * sss, HASH_ITER(hh, sss->rules, re, tmp_re) { allowed_match = re_matchp(re->rule, cmn.community, &match_length); - if(allowed_match != -1) + if(allowed_match != -1) // ... && match_len == strlen(cmn.community) --- if only full matches allowed break; }