[eggheads-patches] PATCH: botflfixes.patch

Peter 'Rattacresh' Backes rtc at rhrk.uni-kl.de
Mon Oct 11 13:28:45 CST 1999


* fixed 100% reproducible SEGV after .tcl setuser botname BOTFL 
+doesntmatter (last context: 'drummers bug') 
* fixed memleak in botfl_pack 
* ASSERTized 


-- Peter 'Rattacresh' Backes, rtc at rhrk.uni-kl.de

-------------- next part --------------
diff -urN eggdrop1.3/doc/UPDATES1.3 eggdrop1.3.29+botflfixes/doc/UPDATES1.3
--- eggdrop1.3/doc/UPDATES1.3	Sun Oct 10 13:53:04 1999
+++ eggdrop1.3.29+botflfixes/doc/UPDATES1.3	Mon Oct 11 01:06:57 1999
@@ -4,6 +4,8 @@
 
 1.3.29
 Foundby   Fixedby   What....
+          rtc       fixed memleak in botfl_pack and SEGV in 
+                    botfl_tcl_set
 ranjha	  Fabian    .help * is now converted to .help all
 Ben	  Fabian    cmd_su doesn't require a passwd for the target user if
                     called by an owner
diff -urN eggdrop1.3/src/flags.c eggdrop1.3.29+botflfixes/src/flags.c
--- eggdrop1.3/src/flags.c	Tue Sep 21 22:16:07 1999
+++ eggdrop1.3.29+botflfixes/src/flags.c	Mon Oct 11 01:05:14 1999
@@ -683,44 +683,30 @@
 
 static int botfl_unpack(struct userrec *u, struct user_entry *e)
 {
-  struct flag_record fr =
-  {FR_BOT, 0, 0, 0, 0, 0};
+  struct flag_record fr = {FR_BOT, 0, 0, 0, 0, 0};
 
+  ASSERT (e != NULL);
+  ASSERT (e->name != NULL);
   context;
-  if (e->name) {
-    char *p;
 
-    p = e->u.list->extra;
-    e->u.list->extra = NULL;
-    list_type_kill(e->u.list);
-    break_down_flags(p, &fr, NULL);
-    e->u.ulong = fr.bot;
-    nfree(p);
-  }
+  break_down_flags(e->u.list->extra, &fr, NULL);
+  list_type_kill(e->u.list);
+  e->u.ulong = fr.bot;
+
   return 1;
 }
 
 static int botfl_pack(struct userrec *u, struct user_entry *e)
 {
   char x[100];
-  struct flag_record fr =
-  {FR_BOT, 0, 0, 0, 0, 0};
-  int l;
+  struct flag_record fr = {FR_BOT, 0, 0, 0, 0, 0};
 
-  if (!e->name) {
-    char *p;
+  fr.bot = e->u.ulong;
+  e->u.list = user_malloc(sizeof(struct list_type));
+  e->u.list->next = NULL;
+  e->u.list->extra = user_malloc (build_flags (x, &fr, NULL) + 1);
+  strcpy(e->u.list->extra, x);
 
-    e->name = user_malloc(strlen(e->type->name) + 1);
-    strcpy(e->name, e->type->name);
-    fr.bot = e->u.ulong;
-    l = build_flags(x, &fr, NULL);
-    p = user_malloc(l + 1);
-    e->u.list = user_malloc(sizeof(struct list_type));
-
-    e->u.list->next = NULL;
-    e->u.list->extra = p;
-    strcpy(p, x);
-  }
   return 1;
 }
 
@@ -785,14 +771,13 @@
 static int botfl_tcl_set(Tcl_Interp * irp, struct userrec *u,
 			 struct user_entry *e, int argc, char **argv)
 {
-  struct flag_record fr =
-  {FR_BOT, 0, 0, 0, 0, 0};
+  struct flag_record fr = {FR_BOT, 0, 0, 0, 0, 0};
 
   BADARGS(4, 4, " handle BOTFL flags");
   if (u->flags & USER_BOT) {
     /* silently ignore for users */
     break_down_flags(argv[3], &fr, NULL);
-    def_set(u, e, (void *) fr.bot);
+    botfl_set(u, e, (void *) fr.bot);
   }
   return TCL_OK;
 }


More information about the Patches mailing list