From f4bfb2bd7a663acfff720ee901463d370266a9c5 Mon Sep 17 00:00:00 2001 From: Pekka Riikonen Date: Wed, 26 Jun 2002 07:42:02 +0000 Subject: [PATCH] Fixed silc_string_regexify to add '^' to start of each string to match explicitly. --- CHANGES | 9 +++++++++ TODO | 2 ++ lib/silcutil/unix/silcunixutil.c | 22 ++++++++++++---------- 3 files changed, 23 insertions(+), 10 deletions(-) diff --git a/CHANGES b/CHANGES index c046e627..b6eb31ec 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,12 @@ +Wed Jun 26 10:38:11 EEST 2002 Pekka Riikonen + + * Fixed a bug in silc_string_regexify which did not add '^' + at the start of each string, and thus the matching was + not explicit. For example ban list iikone@*!*@* would + match also "priikone", which is wrong, it would have to be + *iikone@*!*@* to match also "priikone". Affected + file lib/silcutil/unix/silcunixutil.c. + Tue Jun 25 18:47:39 EEST 2002 Pekka Riikonen * Enable all local server connections before updating client diff --git a/TODO b/TODO index c01886b1..b3e6b13c 100644 --- a/TODO +++ b/TODO @@ -45,6 +45,8 @@ TODO/bugs In SILC Server o Testing + o Close unconfigured client connections in rehash. + o Add a timeout to handling incoming JOIN commands. It should be enforced that JOIN command is executed only once in a second or two seconds. Now it is possible to accept n incoming JOIN commands diff --git a/lib/silcutil/unix/silcunixutil.c b/lib/silcutil/unix/silcunixutil.c index 42b6edac..59266164 100644 --- a/lib/silcutil/unix/silcunixutil.c +++ b/lib/silcutil/unix/silcunixutil.c @@ -38,30 +38,32 @@ char *silc_string_regexify(const char *string) len = strlen(string); count = 4; - for (i = 0; i < len; i++) + for (i = 0; i < len; i++) { if (string[i] == '*' || string[i] == '?') - count++; + count++; /* Will add '.' */ + if (string[i] == ',') + count += 2; /* Will add '|' and '^' */ + } - regex = silc_calloc(len + count, sizeof(*regex)); + regex = silc_calloc(len + count + 1, sizeof(*regex)); count = 0; - regex[count] = '('; - count++; + regex[count++] = '('; + regex[count++] = '^'; for (i = 0; i < len; i++) { if (string[i] == '*' || string[i] == '?') { regex[count] = '.'; count++; } else if (string[i] == ',') { - if (i + 1 == len) + if (i + 2 == len) continue; - regex[count] = '|'; - count++; + regex[count++] = '|'; + regex[count++] = '^'; continue; } - regex[count] = string[i]; - count++; + regex[count++] = string[i]; } regex[count++] = ')'; -- 2.24.0