[cvslog] (2002-12-26 02:22:04 UTC) Module eggdrop1.6: Change committed

cvslog cvs at tsss.org
Wed Dec 25 20:23:00 CST 2002


CVSROOT    : /usr/local/cvsroot
Module     : eggdrop1.6
Commit time: 2002-12-26 02:22:04 UTC
Commited by: Will Buckner <wcc at techmonkeys.org>

Modified files:
     doc/UPDATES1.6 src/Makefile.in src/match.c src/modules.c
     src/patch.h src/proto.h src/tclhash.c src/tclmisc.c
     src/mod/module.h

Log message:

Removed quoting support from wild_match() which fixes several bugs with '\'
characters.

---------------------- diff included ----------------------
Index: eggdrop1.6/doc/UPDATES1.6
diff -u eggdrop1.6/doc/UPDATES1.6:1.435 eggdrop1.6/doc/UPDATES1.6:1.436
--- eggdrop1.6/doc/UPDATES1.6:1.435	Mon Dec 23 21:33:24 2002
+++ eggdrop1.6/doc/UPDATES1.6	Wed Dec 25 20:21:53 2002
@@ -1,10 +1,12 @@
-$Id: UPDATES1.6,v 1.435 2002/12/24 03:33:24 wcc Exp $
+$Id: UPDATES1.6,v 1.436 2002/12/26 02:21:53 wcc Exp $
 
 Changes in Eggdrop: (since v1.6.0)
 ----------------------------------
 
 1.6.14
 Found by  Fixed by  What...
+various   Wcc/      removed quoting support from wild_match() which fixes several
+          zip       bugs with '\' characters
           BarkerJr  show who unlinked a bot when unlinked remotely
           poptix    fixed default setting for the help-path and text-path settings
           The_Dawn  fixed a problem in cmd_kick()/cmd_kickban() where the
Index: eggdrop1.6/src/Makefile.in
diff -u eggdrop1.6/src/Makefile.in:1.15 eggdrop1.6/src/Makefile.in:1.16
--- eggdrop1.6/src/Makefile.in:1.15	Wed Nov 22 21:56:40 2000
+++ eggdrop1.6/src/Makefile.in	Wed Dec 25 20:21:53 2002
@@ -1,5 +1,5 @@
 # Makefile for src/
-# $Id: Makefile.in,v 1.15 2000/11/23 03:56:40 guppy Exp $
+# $Id: Makefile.in,v 1.16 2002/12/26 02:21:53 wcc Exp $
 
 SHELL = @SHELL@
 top_srcdir = @top_srcdir@
@@ -19,9 +19,9 @@
 CPPFLAGS = @CPPFLAGS@
 
 eggdrop_objs = bg.o botcmd.o botmsg.o botnet.o chanprog.o cmds.o dcc.o \
-dccutil.o dns.o flags.o language.o main.o mem.o misc.o misc_file.o \
-modules.o net.o rfc1459.o tcl.o tcldcc.o tclhash.o tclmisc.o \
-tcluser.o userent.o userrec.o users.o
+dccutil.o dns.o flags.o language.o match.o main.o mem.o misc.o misc_file.o \
+modules.o net.o rfc1459.o tcl.o tcldcc.o tclhash.o tclmisc.o tcluser.o \
+userent.o userrec.o users.o
 
 MAKE_GENERIC = $(MAKE) 'MAKE=$(MAKE)' 'CC=$(CC)' 'LD=$(LD)' \
 'STRIP=$(STRIP)' 'CFLGS=$(CFLGS)'
@@ -143,7 +143,7 @@
  compat/compat.h compat/inet_aton.h ../src/main.h compat/snprintf.h \
  compat/memset.h compat/memcpy.h compat/strcasecmp.h compat/strftime.h \
  modules.h mod/modvals.h tandem.h bg.h patch.h
-match.o: ./match.c
+match.o: ./match.c ./main.h
 mem.o: ./mem.c main.h ../config.h lang.h eggdrop.h flags.h proto.h \
  ../lush.h misc_file.h cmdt.h tclegg.h tclhash.h chan.h users.h \
  compat/compat.h compat/inet_aton.h ../src/main.h compat/snprintf.h \
@@ -186,7 +186,7 @@
  proto.h ../lush.h misc_file.h cmdt.h tclegg.h tclhash.h chan.h \
  users.h compat/compat.h compat/inet_aton.h ../src/main.h \
  compat/snprintf.h compat/memset.h compat/memcpy.h compat/strcasecmp.h \
- compat/strftime.h match.c
+ compat/strftime.h
 tclmisc.o: ./tclmisc.c main.h ../config.h lang.h eggdrop.h flags.h \
  proto.h ../lush.h misc_file.h cmdt.h tclegg.h tclhash.h chan.h \
  users.h compat/compat.h compat/inet_aton.h ../src/main.h \
Index: eggdrop1.6/src/match.c
diff -u eggdrop1.6/src/match.c:1.5 eggdrop1.6/src/match.c:1.6
--- eggdrop1.6/src/match.c:1.5	Sun Jan 30 13:26:20 2000
+++ eggdrop1.6/src/match.c	Wed Dec 25 20:21:53 2002
@@ -1,11 +1,9 @@
-/* 
+/*
  * match.c
  *   wildcard matching functions
- *   (rename to reg.c for ircII)
- * 
- * $Id: match.c,v 1.5 2000/01/30 19:26:20 fabian Exp $
- */
-/* 
+ *
+ * $Id: match.c,v 1.6 2002/12/26 02:21:53 wcc Exp $
+ *
  * Once this code was working, I added support for % so that I could
  * use the same code both in Eggdrop and in my IrcII client.
  * Pleased with this, I added the option of a fourth wildcard, ~,
@@ -22,85 +20,21 @@
  *     crf at cfox.bchs.uh.edu
  * 
  * I hereby release this code into the public domain
- * 
- */
-
-/* 
- * This will get us around most of the mess and replace the chunk that
- * was removed from the middle of this file.   --+ Dagmar
- */
-/* 
- * You'll also want to grab the rfc1459.c file or change all rfc_*()
- * calls to the standard library call to make this work with ircII
- * derivatives now.
- */
-
-#ifdef HAVE_CONFIG_H
-#  include <config.h>
-#endif
-
-/* Remove the next line to use this in IrcII */
-#define EGGDROP
-
-/* 
- * Best to leave stuff after this point alone, but go on and change
- * it if you're adventurous...
- */
-
-/* The quoting character -- what overrides wildcards (do not undef) */
-#define QUOTE '\\'
-
-/* The "matches ANYTHING" wildcard (do not undef) */
-#define WILDS '*'
-
-/* The "matches ANY NUMBER OF NON-SPACE CHARS" wildcard (do not undef) */
-#define WILDP '%'
-
-/* The "matches EXACTLY ONE CHARACTER" wildcard (do not undef) */
-#define WILDQ '?'
-
-/* The "matches AT LEAST ONE SPACE" wildcard (undef me to disable!) */
-#define WILDT '~'
-
-/* 
- * This makes sure WILDT doesn't get used in in the IrcII version of
- * this code.  If ya wanna live dangerously, you can remove these 3
- * lines, but WARNING: IT WOULD MAKE THIS CODE INCOMPATIBLE WITH THE
- * CURRENT reg.c OF IrcII!!!  Support for ~ is NOT in the reg.c of
- * IrcII, and adding it may cause compatibility problems, especially
- * in scripts.  If you don't think you have to worry about that, go
- * for it!
- */
-#ifndef EGGDROP
-#undef WILDT
-#endif
-
-/* 
- * If you edit below this line and it stops working, don't even THINK
- * about whining to *ME* about it!
+ *
  */
+#include "main.h"
 
-/* 
- * No problem, you got it wrong anyway, Chris.  You should have gone to
- * uppercase instead of lowercase.  (A really minor mistake)
- */
+#define QUOTE '\\' /* quoting character (overrides wildcards) */
+#define WILDS '*'  /* matches 0 or more characters (including spaces) */
+#define WILDP '%'  /* matches 0 or more non-space characters */
+#define WILDQ '?'  /* matches ecactly one character */
+#define WILDT '~'  /* matches 1 or more spaces */
 
-/* Changing these is probably counter-productive :) */
-#define MATCH (match+saved+sofar)
 #define NOMATCH 0
+#define MATCH (match+sofar)
+#define PERMATCH (match+saved+sofar)
 
-/* 
- * EGGDROP:   wild_match_per(char *m, char *n)
- * IrcII:     wild_match(char *m, char *n)
- * 
- * Features:  Forward, case-insensitive, ?, *, %, ~(optional)
- * Best use:  Generic string matching, such as in IrcII-esque bindings
- */
-#ifdef EGGDROP
-static int wild_match_per(register unsigned char *m, register unsigned char *n)
-#else
-int wild_match(register unsigned char *m, register unsigned char *n)
-#endif
+int _wild_match_per(register unsigned char *m, register unsigned char *n)
 {
   unsigned char *ma = m, *lsm = 0, *lsn = 0, *lpm = 0, *lpn = 0;
   int match = 1, saved = 0;
@@ -110,18 +44,11 @@
   int space;
 #endif
 
-  /* take care of null strings (should never match) */
+  /* null strings should never match */
   if ((m == 0) || (n == 0) || (!*n))
     return NOMATCH;
-  /* (!*m) test used to be here, too, but I got rid of it.  After all,
-   * If (!*n) was false, there must be a character in the name (the
-   * second string), so if the mask is empty it is a non-match.  Since
-   * the algorithm handles this correctly without testing for it here
-   * and this shouldn't be called with null masks anyway, it should be
-   * a bit faster this way */
 
   while (*n) {
-    /* Used to test for (!*m) here, but this scheme seems to work better */
 #ifdef WILDT
     if (*m == WILDT) {		/* Match >=1 space */
       space = 0;		/* Don't need any spaces */
@@ -147,7 +74,7 @@
 	  m--;			/* Search backwards */
 	while ((m > ma) && (*m == '?'));	/* For first non-? char */
 	if ((m > ma) ? ((*m == '*') && (m[-1] != QUOTE)) : (*m == '*'))
-	  return MATCH;		/* nonquoted * = match */
+	  return PERMATCH;		/* nonquoted * = match */
 	break;
       case WILDP:
 	while (*(++m) == WILDP);	/* Zap redundant %s */
@@ -198,7 +125,6 @@
     if (lsm) {			/* Try to fallback on '*' */
       n = ++lsn;
       m = lsm;			/* Restore position */
-      /* Used to test for (!*n) here but it wasn't necessary so it's gone */
       saved = sofar = 0;
       continue;			/* Next char, please */
     }
@@ -206,60 +132,16 @@
   }
   while ((*m == WILDS) || (*m == WILDP))
     m++;			/* Zap leftover %s & *s */
-  return (*m) ? NOMATCH : MATCH;	/* End of both = match */
-}
-
-#ifndef EGGDROP
-
-/* For IrcII compatibility */
-
-int _wild_match(ma, na)
-register unsigned char *ma, *na;
-{
-  return wild_match(ma, na) - 1;	/* Don't think IrcII's code
-					 * actually uses this directly,
-					 * but just in case */
+  return (*m) ? NOMATCH : PERMATCH;	/* End of both = match */
 }
 
-int match(ma, na)
-register unsigned char *ma, *na;
-{
-  return wild_match(ma, na) ? 1 : 0;	/* Returns 1 for match,
-					 * 0 for non-match */
-}
-
-#else
-
-/* 
- * Remaining code is not used by IrcII
- */
-
-/* 
- * For this matcher, sofar's high bit is used as a flag of whether or
- * not we are quoting.  The other matchers don't need this because
- * when you're going forward, you just skip over the quote char.
- */
-#define UNQUOTED (0x7FFF)
-#define QUOTED   (0x8000)
-
-#undef MATCH
-#define MATCH ((match+sofar)&UNQUOTED)
-
-/* 
- * EGGDROP:   wild_match(char *ma, char *na)
- * IrcII:     NOT USED
- * 
- * Features:  Backwards, case-insensitive, ?, *
- * Best use:  Matching of hostmasks (since they are likely to begin
- *            with a * rather than end with one).
- */
 int _wild_match(register unsigned char *m, register unsigned char *n)
 {
   unsigned char *ma = m, *na = n, *lsm = 0, *lsn = 0;
   int match = 1;
   register int sofar = 0;
 
-  /* take care of null strings (should never match) */
+  /* null strings should never match */
   if ((ma == 0) || (na == 0) || (!*ma) || (!*na))
     return NOMATCH;
   /* find the end of each string */
@@ -269,53 +151,38 @@
     n--;
 
   while (n >= na) {
-    if ((m <= ma) || (m[-1] != QUOTE)) {	/* Only look if no quote */
-      switch (*m) {
-      case WILDS:		/* Matches anything */
-	do
-	  m--;			/* Zap redundant wilds */
-	while ((m >= ma) && ((*m == WILDS) || (*m == WILDP)));
-	if ((m >= ma) && (*m == '\\'))
-	  m++;			/* Keep quoted wildcard! */
-	lsm = m;
-	lsn = n;
-	match += sofar;
-	sofar = 0;		/* Update fallback pos */
-	continue;		/* Next char, please */
-      case WILDQ:
-	m--;
-	n--;
-	continue;		/* '?' always matches */
-      }
-      sofar &= UNQUOTED;	/* Remember not quoted */
-    } else
-      sofar |= QUOTED;		/* Remember quoted */
-    if (rfc_toupper(*m) == rfc_toupper(*n)) {	/* If matching char */
+    switch (*m) {
+    case WILDS:  /* Matches anything */
+      do
+        m--;  /* Zap redundant wilds */
+      while ((m >= ma) && (*m == WILDS));
+      lsm = m;
+      lsn = n;
+      match += sofar;
+      sofar = 0;  /* Update fallback pos */
+      continue;  /* Next char, please */
+    case WILDQ:
       m--;
       n--;
-      sofar++;			/* Tally the match */
-      if (sofar & QUOTED)
-	m--;			/* Skip the quote char */
-      continue;			/* Next char, please */
+      continue;  /* '?' always matches */
+    }
+    if (rfc_toupper(*m) == rfc_toupper(*n)) {  /* If matching char */
+      m--;
+      n--;
+      sofar++;  /* Tally the match */
+      continue;  /* Next char, please */
     }
-    if (lsm) {			/* To to fallback on '*' */
+    if (lsm) {  /* To to fallback on '*' */
       n = --lsn;
       m = lsm;
       if (n < na)
-	lsm = 0;		/* Rewind to saved pos */
+	lsm = 0;  /* Rewind to saved pos */
       sofar = 0;
-      continue;			/* Next char, please */
+      continue;  /* Next char, please */
     }
-    return NOMATCH;		/* No fallback=No match */
+    return NOMATCH;  /* No fallback=No match */
   }
-  while ((m >= ma) && ((*m == WILDS) || (*m == WILDP)))
-    m--;			/* Zap leftover %s & *s */
-  return (m >= ma) ? NOMATCH : MATCH;	/* Start of both = match */
+  while ((m >= ma) && (*m == WILDS))
+    m--;  /* Zap leftover %s & *s */
+  return (m >= ma) ? NOMATCH : MATCH;  /* Start of both = match */
 }
-
-/* 
- * For this matcher, no "saved" is used to track "%" and no special quoting
- * ability is needed, so we just have (match+sofar) as the result.
- */
-
-#endif
Index: eggdrop1.6/src/mod/module.h
diff -u eggdrop1.6/src/mod/module.h:1.62 eggdrop1.6/src/mod/module.h:1.63
--- eggdrop1.6/src/mod/module.h:1.62	Mon Dec 23 20:30:06 2002
+++ eggdrop1.6/src/mod/module.h	Wed Dec 25 20:21:54 2002
@@ -1,7 +1,7 @@
 /*
  * module.h
  *
- * $Id: module.h,v 1.62 2002/12/24 02:30:06 wcc Exp $
+ * $Id: module.h,v 1.63 2002/12/26 02:21:54 wcc Exp $
  */
 /*
  * Copyright (C) 1997 Robey Pointer
@@ -457,6 +457,8 @@
 #define MD5_Init ((void (*)(MD5_CTX))global[277])
 #define MD5_Update ((void (*)(MD5_CTX *, void *, unsigned long))global[278])
 #define MD5_Final ((void (*)(unsigned char *, MD5_CTX *))global[279])
+/* 280 - 283 */
+#define wild_match_per ((int (*)(const char *, const char *))global[280])
 
 /* This is for blowfish module, couldnt be bothered making a whole new .h
  * file for it ;)
Index: eggdrop1.6/src/modules.c
diff -u eggdrop1.6/src/modules.c:1.70 eggdrop1.6/src/modules.c:1.71
--- eggdrop1.6/src/modules.c:1.70	Mon Dec 23 20:30:05 2002
+++ eggdrop1.6/src/modules.c	Wed Dec 25 20:21:53 2002
@@ -4,7 +4,7 @@
  * 
  * by Darrin Smith (beldin at light.iinet.net.au)
  * 
- * $Id: modules.c,v 1.70 2002/12/24 02:30:05 wcc Exp $
+ * $Id: modules.c,v 1.71 2002/12/26 02:21:53 wcc Exp $
  */
 /* 
  * Copyright (C) 1997 Robey Pointer
@@ -544,7 +544,9 @@
   (Function) tell_bottree,
   (Function) MD5_Init,
   (Function) MD5_Update,
-  (Function) MD5_Final
+  (Function) MD5_Final,
+  /* 280 - 283 */
+  (Function) _wild_match_per
 };
 
 void init_modules(void)
Index: eggdrop1.6/src/patch.h
diff -u eggdrop1.6/src/patch.h:1.862 eggdrop1.6/src/patch.h:1.863
--- eggdrop1.6/src/patch.h:1.862	Mon Dec 23 21:33:24 2002
+++ eggdrop1.6/src/patch.h	Wed Dec 25 20:21:53 2002
@@ -10,7 +10,7 @@
  * statement, leave the rest of the file alone, this allows better
  * overlapping patches.
  *
- * $Id: patch.h,v 1.862 2002/12/24 03:33:24 wcc Exp $
+ * $Id: patch.h,v 1.863 2002/12/26 02:21:53 wcc Exp $
  */
 /*
  * Copyright (C) 1997 Robey Pointer
@@ -41,12 +41,12 @@
  *
  *
  */
-patch("1040700578");		/* current unixtime */
+patch("1040868866");		/* current unixtime */
 /*
  *
  *
  */
-patch("unlinkedby");
+patch("match-escape");
 /*
  *
  *
Index: eggdrop1.6/src/proto.h
diff -u eggdrop1.6/src/proto.h:1.50 eggdrop1.6/src/proto.h:1.51
--- eggdrop1.6/src/proto.h:1.50	Mon Dec 23 21:33:24 2002
+++ eggdrop1.6/src/proto.h	Wed Dec 25 20:21:53 2002
@@ -7,7 +7,7 @@
  * because they use structures in those
  * (saves including those .h files EVERY time) - Beldin
  *
- * $Id: proto.h,v 1.50 2002/12/24 03:33:24 wcc Exp $
+ * $Id: proto.h,v 1.51 2002/12/26 02:21:53 wcc Exp $
  */
 /*
  * Copyright (C) 1997 Robey Pointer
@@ -184,7 +184,9 @@
 
 /* match.c */
 int _wild_match(register unsigned char *, register unsigned char *);
+int _wild_match_per(register unsigned char *, register unsigned char *);
 #define wild_match(a,b) _wild_match((unsigned char *)(a),(unsigned char *)(b))
+#define wild_match_per(a,b) _wild_match_per((unsigned char *)(a),(unsigned char *)(b))
 
 /* mem.c */
 void *n_malloc(int, const char *, int);
Index: eggdrop1.6/src/tclhash.c
diff -u eggdrop1.6/src/tclhash.c:1.37 eggdrop1.6/src/tclhash.c:1.38
--- eggdrop1.6/src/tclhash.c:1.37	Mon Dec 23 20:30:05 2002
+++ eggdrop1.6/src/tclhash.c	Wed Dec 25 20:21:53 2002
@@ -7,7 +7,7 @@
  *   (non-Tcl) procedure lookups for msg/dcc/file commands
  *   (Tcl) binding internal procedures to msg/dcc/file commands
  *
- * $Id: tclhash.c,v 1.37 2002/12/24 02:30:05 wcc Exp $
+ * $Id: tclhash.c,v 1.38 2002/12/26 02:21:53 wcc Exp $
  */
 /*
  * Copyright (C) 1997 Robey Pointer
@@ -31,7 +31,6 @@
 #include "main.h"
 #include "chan.h"
 #include "users.h"
-#include "match.c"
 
 extern Tcl_Interp	*interp;
 extern struct dcc_t	*dcc;
@@ -717,7 +716,7 @@
       ok = !strcmp(match, tm->mask);
       break;
     case MATCH_MASK:
-      ok = wild_match_per((unsigned char *) tm->mask, (unsigned char *) match);
+      ok = wild_match_per(tm->mask, match);
       break;
     default:
       ok = 0;
@@ -1095,9 +1094,9 @@
 	  int	ok = 0;
 
           if (patmatc == 1) {
-            if (wild_match(name, tl->name) ||
-                wild_match(name, tm->mask) ||
-                wild_match(name, tc->func_name))
+            if (wild_match_per(name, tl->name) ||
+                wild_match_per(name, tm->mask) ||
+                wild_match_per(name, tc->func_name))
 	      ok = 1;
           } else
 	    ok = 1;
Index: eggdrop1.6/src/tclmisc.c
diff -u eggdrop1.6/src/tclmisc.c:1.32 eggdrop1.6/src/tclmisc.c:1.33
--- eggdrop1.6/src/tclmisc.c:1.32	Mon Dec 23 20:30:05 2002
+++ eggdrop1.6/src/tclmisc.c	Wed Dec 25 20:21:53 2002
@@ -2,7 +2,7 @@
  * tclmisc.c -- handles:
  *   Tcl stubs for everything else
  *
- * $Id: tclmisc.c,v 1.32 2002/12/24 02:30:05 wcc Exp $
+ * $Id: tclmisc.c,v 1.33 2002/12/26 02:21:53 wcc Exp $
  */
 /*
  * Copyright (C) 1997 Robey Pointer
@@ -200,9 +200,9 @@
 	if (tc->attributes & TC_DELETED)
 	  continue;
         if (matching &&
-	    !wild_match(argv[1], tl->name) &&
-            !wild_match(argv[1], tm->mask) &&
-            !wild_match(argv[1], tc->func_name))
+            !wild_match_per(argv[1], tl->name) &&
+            !wild_match_per(argv[1], tm->mask) &&
+            !wild_match_per(argv[1], tc->func_name))
           continue;
 	build_flags(flg, &(tc->flags), NULL);
         egg_snprintf(hits, sizeof hits, "%i", (int) tc->hits);
----------------------- End of diff -----------------------



More information about the Changes mailing list