Fixed silc_string_regexify to add '^' to start of each string
authorPekka Riikonen <priikone@silcnet.org>
Wed, 26 Jun 2002 07:42:02 +0000 (07:42 +0000)
committerPekka Riikonen <priikone@silcnet.org>
Wed, 26 Jun 2002 07:42:02 +0000 (07:42 +0000)
to match explicitly.

CHANGES
TODO
lib/silcutil/unix/silcunixutil.c

diff --git a/CHANGES b/CHANGES
index c046e6276c6d44e9a03fc1c52a201e182a9c68c6..b6eb31ec3e502448e9cb5630cc472e1ad8cf797e 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,12 @@
+Wed Jun 26 10:38:11 EEST 2002 Pekka Riikonen <priikone@silcnet.org>
+
+       * 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 <priikone@silcnet.org>
 
        * Enable all local server connections before updating client
diff --git a/TODO b/TODO
index c01886b18d0de35ed8aba4ae16374db24ea2e271..b3e6b13c934fd28bef11c240cb0a967239aaba99 100644 (file)
--- 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
index 42b6edace41826d5857a2355067cc547d682899e..592661649d4ded3542bb414027626201755773b5 100644 (file)
@@ -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++] = ')';