From 1d048c59a9b16a48e44a6dd3c4541734dd5826cb Mon Sep 17 00:00:00 2001 From: Logan007 Date: Sat, 8 Aug 2020 22:45:34 +0545 Subject: [PATCH] polished reg exp handling and fixed bugs --- src/sn.c | 2 +- src/sn_utils.c | 13 ++++++++----- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/sn.c b/src/sn.c index a263cba..f5f53f3 100644 --- a/src/sn.c +++ b/src/sn.c @@ -100,7 +100,7 @@ static int load_allowed_sn_community(n2n_sn_t *sss, char *path) { fclose(fd); - if (num_regex>0 || num_communities>0 ) + if ((num_regex + num_communities) == 0) { traceEvent(TRACE_WARNING, "File %s does not contain any valid community names or regular expressions", path); return -1; diff --git a/src/sn_utils.c b/src/sn_utils.c index 7ff22d4..c7a73ce 100644 --- a/src/sn_utils.c +++ b/src/sn_utils.c @@ -253,6 +253,9 @@ void sn_term(n2n_sn_t *sss) HASH_ITER(hh, sss->rules, re, tmp_re) { HASH_DEL(sss->rules, re); + if (NULL!=re->rule) { + free(re->rule); + } free(re); } } @@ -833,11 +836,11 @@ static int process_udp(n2n_sn_t * sss, break; } } - } - if(match != 1) { - traceEvent(TRACE_INFO, "Discarded registration: unallowed community '%s'", - (char*)cmn.community); - return -1; + if(match != 1) { + traceEvent(TRACE_INFO, "Discarded registration: unallowed community '%s'", + (char*)cmn.community); + return -1; + } } if(!comm && (!sss->lock_communities || (match == 1))) {