Jelajahi Sumber

Fixed bug with partyline chat -found by ryguy.
Fixed memory leak with partyline chat.
Reverted some mem.c crap.


svn: 76

Bryan Drewery 23 tahun lalu
induk
melakukan
7e8cb338b0
7 mengubah file dengan 71 tambahan dan 54 penghapusan
  1. 3 7
      src/dcc.c
  2. 8 8
      src/dccutil.c
  3. 30 26
      src/mem.c
  4. 22 6
      src/misc.c
  5. 0 1
      src/proto.h
  6. 3 4
      src/settings.c
  7. 5 2
      src/userrec.c

+ 3 - 7
src/dcc.c

@@ -1044,16 +1044,12 @@ static void dcc_chat(int idx, char *buf, int i)
     else
       *d = 0;
     if (buf[0]) {		/* Nothing to say - maybe paging... */
-      char *tmppass;
 
-      tmppass = nmalloc(strlen(buf)+1);
-      strcpy(tmppass, buf);
-      if (u_pass_match(dcc[idx].user, tmppass)) { //user said their password :)
+      if (u_pass_match(dcc[idx].user, buf)) { //user said their password :)
         dprintf(idx, "Sure you want that going to the partyline? ;) (msg to partyline halted.)\n");
-        if (tmppass)
-          nfree(tmppass);
       } else if ((!strncmp(buf,dcc_prefix,strlen(dcc_prefix))) || (dcc[idx].u.chat->channel < 0)) {
-	if (!strncmp(buf,dcc_prefix,strlen(dcc_prefix)))
+
+	if (!strncmp(buf, dcc_prefix,strlen(dcc_prefix)))
 	  buf++;
 	v = newsplit(&buf);
 	rmspace(buf);

+ 8 - 8
src/dccutil.c

@@ -83,14 +83,14 @@ extern void (*qserver) (int, char *, int);
 
 void dprintf EGG_VARARGS_DEF(int, arg1)
 {
-  static char buf[1024];
-  char *format, buf3[1024] = "", buf2[1024] = "", c; 
+  static char buf[1624];
+  char *format, buf3[1624] = "", buf2[1624] = "", c; 
   int idx, len, id;
   va_list va;
 
   idx = EGG_VARARGS_START(int, arg1, va);
   format = va_arg(va, char *);
-  egg_vsnprintf(buf, 1023, format, va);
+  egg_vsnprintf(buf, 1623, format, va);
   va_end(va);
   /* We can not use the return value vsnprintf() to determine where
    * to null terminate. The C99 standard specifies that vsnprintf()
@@ -198,10 +198,10 @@ broke:
     }
     return;
   } else {
-    if (len > 500) {		/* Truncate to fit */
-      buf[500] = 0;
+    if (len > 1000) {		/* Truncate to fit */
+      buf[1000] = 0;
       strcat(buf, "\n");
-      len = 501;
+      len = 1001;
     }
 
     if (dcc[idx].type && ((long) (dcc[idx].type->output) == 1)) {
@@ -274,9 +274,9 @@ void dcc_chatter(int idx)
 Context;
   if (glob_master(fr)) {
     if ((tands+1) > 1)
-      dprintf(idx, STR("There is \002-%d- bot\002 currently linked.\n"), tands + 1);
-    else
       dprintf(idx, STR("There are \002-%d- bots\002 currently linked.\n"), tands + 1);
+    else
+      dprintf(idx, STR("There is \002-%d- bot\002 currently linked.\n"), tands + 1);
   }
   show_channels(idx, NULL);
 Context;

+ 30 - 26
src/mem.c

@@ -133,31 +133,35 @@ void debug_mem_to_dcc(int idx)
     if (p)
       *p = 0;
     l = memtbl[i].size;
-    if (!strcmp(fn, "xlanguage.c"))
+//    if (fn[0] == 'x') {
+//      p = &fn;
+//      p++;
+//    }
+    if (!strcmp(fn, "language.c"))
       use[0] += l;
-    else if (!strcmp(fn, "xchanprog.c"))
+    else if (!strcmp(fn, "chanprog.c"))
       use[1] += l;
-    else if (!strcmp(fn, "xmisc.c"))
+    else if (!strcmp(fn, "misc.c"))
       use[2] += l;
-    else if (!strcmp(fn, "xuserrec.c"))
+    else if (!strcmp(fn, "userrec.c"))
       use[3] += l;
-    else if (!strcmp(fn, "xnet.c"))
+    else if (!strcmp(fn, "net.c"))
       use[4] += l;
-    else if (!strcmp(fn, "xdccutil.c"))
+    else if (!strcmp(fn, "dccutil.c"))
       use[5] += l;
-    else if (!strcmp(fn, "xbotnet.c"))
+    else if (!strcmp(fn, "botnet.c"))
       use[6] += l;
-    else if (!strcmp(fn, "xtcl.c"))
+    else if (!strcmp(fn, "tcl.c"))
       use[7] += l;
-    else if (!strcmp(fn, "xtclhash.c"))
+    else if (!strcmp(fn, "tclhash.c"))
       use[8] += l;
-    else if (!strcmp(fn, "xtclmisc.c"))
+    else if (!strcmp(fn, "tclmisc.c"))
       use[9] += l;
-    else if (!strcmp(fn, "xmodules.c"))
+    else if (!strcmp(fn, "modules.c"))
       use[10] += l;
-    else if (!strcmp(fn, "xtcldcc.c"))
+    else if (!strcmp(fn, "tcldcc.c"))
       use[11] += l;
-    else if (!strcmp(fn, "xdns.c"))
+    else if (!strcmp(fn, "dns.c"))
       use[12] += l;
     else if (p) {
       for (me = module_list; me; me = me->next)
@@ -169,43 +173,43 @@ void debug_mem_to_dcc(int idx)
   for (i = 0; i < MAX_MEM; i++) {
     switch (i) {
     case 0:
-      strcpy(fn, "xlanguage.c");
+      strcpy(fn, "language.c");
       break;
     case 1:
-      strcpy(fn, "xchanprog.c");
+      strcpy(fn, "chanprog.c");
       break;
     case 2:
-      strcpy(fn, "xmisc.c");
+      strcpy(fn, "misc.c");
       break;
     case 3:
-      strcpy(fn, "xuserrec.c");
+      strcpy(fn, "userrec.c");
       break;
     case 4:
-      strcpy(fn, "xnet.c");
+      strcpy(fn, "net.c");
       break;
     case 5:
-      strcpy(fn, "xdccutil.c");
+      strcpy(fn, "dccutil.c");
       break;
     case 6:
-      strcpy(fn, "xbotnet.c");
+      strcpy(fn, "botnet.c");
       break;
     case 7:
-      strcpy(fn, "xtcl.c");
+      strcpy(fn, "tcl.c");
       break;
     case 8:
-      strcpy(fn, "xtclhash.c");
+      strcpy(fn, "tclhash.c");
       break;
     case 9:
-      strcpy(fn, "xtclmisc.c");
+      strcpy(fn, "tclmisc.c");
       break;
     case 10:
-      strcpy(fn, "xmodules.c");
+      strcpy(fn, "modules.c");
       break;
     case 11:
-      strcpy(fn, "xtcldcc.c");
+      strcpy(fn, "tcldcc.c");
       break;
     case 12:
-      strcpy(fn, "xdns.c");
+      strcpy(fn, "dns.c");
       break;
     }
     if (use[i] == exp[i]) {

+ 22 - 6
src/misc.c

@@ -926,14 +926,27 @@ void daysdur(time_t now, time_t then, char *out)
   strcat(out, s);
 }
 /* show l33t banner */
+
+#define w1 
+
+char *wbanner() {
+  int r;
+  r=random();
+  switch (r % 7) {
+   case 0: return STR("                       .__  __  .__\n__  _  ______________  |__|/  |_|  |__\n\\ \\/ \\/ /\\_  __ \\__  \\ |  \\   __\\  |  \\\n \\     /  |  | \\// __ \\|  ||  | |   Y  \\\n  \\/\\_/   |__|  (____  /__||__| |___|  /\n                     \\/              \\/\n");
+   case 1: return STR("                    _ _   _     \n__      ___ __ __ _(_) |_| |__  \n\\ \\ /\\ / / '__/ _` | | __| '_ \\ \n \\ V  V /| | | (_| | | |_| | | |\n  \\_/\\_/ |_|  \\__,_|_|\\__|_| |_|\n");
+   case 2: return STR("@@@  @@@  @@@  @@@@@@@    @@@@@@   @@@  @@@@@@@  @@@  @@@\n@@@  @@@  @@@  @@@@@@@@  @@@@@@@@  @@@  @@@@@@@  @@@  @@@\n@@!  @@!  @@!  @@!  @@@  @@!  @@@  @@!    @@!    @@!  @@@\n!@!  !@!  !@!  !@!  @!@  !@!  @!@  !@!    !@!    !@!  @!@\n@!!  !!@  @!@  @!@!!@!   @!@!@!@!  !!@    @!!    @!@!@!@!\n!@!  !!!  !@!  !!@!@!    !!!@!!!!  !!!    !!!    !!!@!!!!\n!!\:  !!\:  !!\:  !!\: \:!!   !!\:  !!!  !!\:    !!\:    !!\:  !!!\n\:!\:  \:!\:  \:!\:  \:!\:  !\:!  \:!\:  !\:!  \:!\:    \:!\:    \:!\:  !\:!\n \:\:\:\: \:\: \:\:\:   \:\:   \:\:\:  \:\:   \:\:\:   \:\:     \:\:    \:\:   \:\:\:\n  \:\: \:  \: \:     \:   \: \:   \:   \: \:  \:       \:      \:   \: \:\n");
+   case 3: return STR("                                     o8o      .   oooo\n                                     `\"'    .o8   `888\noooo oooo    ooo oooo d8b  .oooo.   oooo  .o888oo  888 .oo.\n `88. `88.  .8'  `888\"\"8P `P  )88b  `888    888    888P\"Y88b\n  `88..]88..8'    888      .oP\"888   888    888    888   888\n   `888'`888'     888     d8(  888   888    888 .  888   888\n    `8'  `8'     d888b    `Y888\"\"8o o888o   \"888\" o888o o888o\n");
+   case 4: return STR("                                                                   *\n                                                 *         *     **\n**                                              ***       **     **\n**                                               *        **     **\n **    ***    ****     ***  ****                        ******** **\n  **    ***     ***  *  **** **** *    ****    ***     ********  **  ***\n  **     ***     ****    **   ****    * ***  *  ***       **     ** * ***\n  **      **      **     **          *   ****    **       **     ***   ***\n  **      **      **     **         **    **     **       **     **     **\n  **      **      **     **         **    **     **       **     **     **\n  **      **      **     **         **    **     **       **     **     **\n  **      **      *      **         **    **     **       **     **     **\n   ******* *******       ***        **    **     **       **     **     **\n    *****   *****         ***        ***** **    *** *     **    **     **\n                                      ***   **    ***             **    **\n                                                                        *\n                                                                       *\n                                                                      *\n                                                                     *\n");
+   case 5: return STR(" :::  ===  === :::====  :::====  ::: :::==== :::  ===\n :::  ===  === :::  === :::  === ::: :::==== :::  ===\n ===  ===  === =======  ======== ===   ===   ========\n  ===========  === ===  ===  === ===   ===   ===  ===\n   ==== ====   ===  === ===  === ===   ===   ===  ===\n");
+   case 6: return STR(" _  _  _  ______ _______ _____ _______ _     _\n |  |  | |_____/ |_____|   |      |    |_____|\n\n |__|__| |    \\_ |     | __|__    |    |     |\n");
+  }
+  return "";
+}
+
 void show_banner(int idx)
 {
-  dprintf(idx, STR("                    _ _   _     \n"));
-  dprintf(idx, STR("__      ___ __ __ _(_) |_| |__  \n"));
-  dprintf(idx, STR("\\ \\ /\\ / / '__/ _` | | __| '_ \\ \n"));
-  dprintf(idx, STR(" \\ V  V /| | | (_| | | |_| | | |\n"));
-  dprintf(idx, STR("  \\_/\\_/ |_|  \\__,_|_|\\__|_| |_|\n"));
-  dprintf(idx, STR("           by bryan          \n"));
+  dprintf(idx, "%s\n", wbanner());
   dprintf(idx, STR("info, bugs, suggestions, comments:\n- http://www.shatow.net/wraith/ -\n"));
 }
 
@@ -1027,6 +1040,9 @@ void putlog EGG_VARARGS_DEF(int, arg1)
   time_t now2 = time(NULL);
 #endif
   struct tm *t;
+#ifdef LEAF
+  t = 0;
+#endif
   type = EGG_VARARGS_START(int, arg1, va);
   chname = va_arg(va, char *);
   format = va_arg(va, char *);

+ 0 - 1
src/proto.h

@@ -209,7 +209,6 @@ char *progname();
 void init_settings();
 
 /* misc.c */
-char *wbanner();
 char *replace(char *, char *, char *);
 #ifdef S_GARBLESTRINGS
 char *degarble(int, char *);

+ 3 - 4
src/settings.c

@@ -16,8 +16,7 @@ char netpass[16], thepass[33], dcc_prefix[1], owners[2048], hubs[2048];
 //Change everything..
 #define NETPASS STR("kd8e3nchasd93dk") //Just 15 random chars here..
 #define THEPASS STR("d166239eb0558fc14c25a0826d20286d") //this md5 hash will be used for various purposes..
-#define DCCPREFIX STR("!") //This is the cmd prefix for dcc, ie: .cmd could be "."
-
+#define DCCPREFIX "!" //This is the cmd prefix for dcc, ie: .cmd could be "."
 
 //You can define an infinite ammount of hubs/owners.
 //All hubs must be added/defined in this, owners can be later added via partyline.
@@ -81,7 +80,7 @@ void init_settings() {
   snprintf(hubs, sizeof hubs, HUBS);
   snprintf(netpass, sizeof netpass, NETPASS); 
   snprintf(thepass, sizeof thepass, THEPASS);
-  snprintf(dcc_prefix, sizeof dcc_prefix, DCCPREFIX);
+  sprintf(dcc_prefix, DCCPREFIX);
   if (SDEBUG)
-    printf(STR("netpass: %s thepass: %s\n"), netpass, thepass);
+    printf(STR("dcc_prefix: %s netpass: %s thepass: %s\n"), dcc_prefix, netpass, thepass);
 }

+ 5 - 2
src/userrec.c

@@ -368,12 +368,15 @@ struct userrec *get_user_by_equal_host(char *host)
 /* Try: pass_match_by_host("-",host)
  * will return 1 if no password is set for that host
  */
-int u_pass_match(struct userrec *u, char *pass)
+int u_pass_match(struct userrec *u, char *in)
 {
-  char *cmp, new[32];
+  char *cmp, new[32], pass[16];
 
   if (!u)
     return 0;
+
+  snprintf(pass, sizeof pass, "%s", in);
+
   cmp = get_user(&USERENTRY_PASS, u);
   if (!cmp && (!pass[0] || (pass[0] == '-')))
     return 1;