Forráskód Böngészése

* Made a MAXPASSLEN
* Fixed several bugs associated with passes


svn: 1267

Bryan Drewery 22 éve
szülő
commit
edffa072e6
9 módosított fájl, 45 hozzáadás és 47 törlés
  1. 1 0
      doc/UPDATES
  2. 23 23
      src/cmds.c
  3. 4 4
      src/crypt.c
  4. 3 0
      src/eggdrop.h
  5. 4 10
      src/makesettings.c
  6. 3 3
      src/mod/irc.mod/cmdsirc.c
  7. 2 2
      src/mod/irc.mod/msgcmds.c
  8. 2 2
      src/userent.c
  9. 3 3
      src/userrec.c

+ 1 - 0
doc/UPDATES

@@ -38,6 +38,7 @@ This is a summary of ChangeLog basically.
 * cmd_mns_host now accepts multiple hosts
 * Fixed cmd_comment to work like cmd_whois/match with regards to accessing higher level users.
 * Added proper support for $b/$u 
+* msg_cmd_PASS/cmd_adduser/+user were flawed. Displayed wrong length of ACTUAL set pass
 
 1.1.9
 

+ 23 - 23
src/cmds.c

@@ -622,7 +622,7 @@ static void cmd_back(struct userrec *u, int idx, char *par)
 
 static void cmd_newpass(struct userrec *u, int idx, char *par)
 {
-  char *new = NULL, pass[16] = "";
+  char *new = NULL, pass[MAXPASSLEN + 1] = "";
 
   putlog(LOG_CMDS, "*", "#%s# newpass...", dcc[idx].nick);
   if (!par[0]) {
@@ -632,7 +632,7 @@ static void cmd_newpass(struct userrec *u, int idx, char *par)
   new = newsplit(&par);
 
   if (!strcmp(new, "rand")) {
-    make_rand_str(pass, 15);
+    make_rand_str(pass, MAXPASSLEN);
   } else {
     if (strlen(new) < 6) {
       dprintf(idx, "Please use at least 6 characters.\n");
@@ -641,8 +641,8 @@ static void cmd_newpass(struct userrec *u, int idx, char *par)
       egg_snprintf(pass, sizeof pass, "%s", new);
     }
   }
-  if (strlen(pass) > 15)
-    pass[15] = 0;
+  if (strlen(pass) > MAXPASSLEN)
+    pass[MAXPASSLEN] = 0;
 
   if (!goodpass(pass, idx, NULL))
     return;
@@ -656,7 +656,7 @@ static void cmd_newpass(struct userrec *u, int idx, char *par)
 
 static void cmd_secpass(struct userrec *u, int idx, char *par)
 {
-  char *new = NULL, pass[16] = "";
+  char *new = NULL, pass[MAXPASSLEN + 1] = "";
 
   putlog(LOG_CMDS, "*", "#%s# secpass...", dcc[idx].nick);
   if (!par[0]) {
@@ -666,7 +666,7 @@ static void cmd_secpass(struct userrec *u, int idx, char *par)
   new = newsplit(&par);
 
   if (!strcmp(new, "rand")) {
-    make_rand_str(pass, 15);
+    make_rand_str(pass, MAXPASSLEN);
   } else {
     if (strlen(new) < 6) {
       dprintf(idx, "Please use at least 6 characters.\n");
@@ -675,8 +675,8 @@ static void cmd_secpass(struct userrec *u, int idx, char *par)
       egg_snprintf(pass, sizeof pass, "%s", new);
     }
   }
-  if (strlen(pass) > 15)
-    pass[15] = 0;
+  if (strlen(pass) > MAXPASSLEN)
+    pass[MAXPASSLEN] = 0;
   set_user(&USERENTRY_SECPASS, u, pass);
   dprintf(idx, "Changed your secpass to: %s\n", pass);
 #ifdef HUB
@@ -1415,7 +1415,7 @@ static void cmd_handle(struct userrec *u, int idx, char *par)
 #ifdef HUB
 static void cmd_chpass(struct userrec *u, int idx, char *par)
 {
-  char *handle = NULL, *new = NULL, pass[16] = "";
+  char *handle = NULL, *new = NULL, pass[MAXPASSLEN] = "";
   int atr = u ? u->flags : 0, l;
 
   if (!par[0])
@@ -1442,10 +1442,10 @@ static void cmd_chpass(struct userrec *u, int idx, char *par)
     } else {
       int good = 0;
       l = strlen(new = newsplit(&par));
-      if (l > 15)
-	new[15] = 0;
+      if (l > MAXPASSLEN)
+	new[MAXPASSLEN] = 0;
       if (!strcmp(new, "rand")) {
-        make_rand_str(pass, 15);
+        make_rand_str(pass, MAXPASSLEN);
         good = 1;
       } else {
         if (goodpass(new, idx, NULL)) {
@@ -1453,8 +1453,8 @@ static void cmd_chpass(struct userrec *u, int idx, char *par)
           good = 1;
         }
       }
-      if (strlen(pass) > 15)
-        pass[15] = 0;
+      if (strlen(pass) > MAXPASSLEN)
+        pass[MAXPASSLEN] = 0;
 
       if (good) {
         set_user(&USERENTRY_PASS, u, pass);
@@ -1470,7 +1470,7 @@ static void cmd_chpass(struct userrec *u, int idx, char *par)
 
 static void cmd_chsecpass(struct userrec *u, int idx, char *par)
 {
-  char *handle = NULL, *new = NULL, pass[16] = "";
+  char *handle = NULL, *new = NULL, pass[MAXPASSLEN + 1] = "";
   int atr = u ? u->flags : 0, l;
 
   if (!par[0])
@@ -1497,10 +1497,10 @@ static void cmd_chsecpass(struct userrec *u, int idx, char *par)
     } else {
 
       l = strlen(new = newsplit(&par));
-      if (l > 15)
-	new[15] = 0;
+      if (l > MAXPASSLEN)
+	new[MAXPASSLEN] = 0;
       if (!strcmp(new, "rand")) {
-        make_rand_str(pass, 15);
+        make_rand_str(pass, MAXPASSLEN);
       } else {
         if (strlen(new) < 6) {
           dprintf(idx, "Please use at least 6 characters.\n");
@@ -1509,8 +1509,8 @@ static void cmd_chsecpass(struct userrec *u, int idx, char *par)
           egg_snprintf(pass, sizeof pass, "%s", new);
         }
       }
-      if (strlen(pass) > 15)
-        pass[15] = 0;
+      if (strlen(pass) > MAXPASSLEN)
+        pass[MAXPASSLEN] = 0;
       set_user(&USERENTRY_SECPASS, u, pass);
       putlog(LOG_CMDS, "*", "#%s# chsecpass %s [something]", dcc[idx].nick, handle);
       dprintf(idx, "Secpass for '%s' changed to: %s\n", handle, pass);
@@ -3342,7 +3342,7 @@ static void cmd_pls_user(struct userrec *u, int idx, char *par)
     dprintf(idx, "Hey! That's MY name!\n");
   else {
     struct userrec *u2 = NULL;
-    char tmp[50] = "", s[16] = "", s2[17] = "";
+    char tmp[50] = "", s[MAXPASSLEN + 1] = "", s2[MAXPASSLEN + 1] = "";
 
     userlist = adduser(userlist, handle, host, "-", USER_DEFAULT, 0);
     u2 = get_user_by_handle(userlist, handle);
@@ -3354,10 +3354,10 @@ static void cmd_pls_user(struct userrec *u, int idx, char *par)
       set_user(&USERENTRY_HOSTS, u2, host);
       dprintf(idx, "Added host '%s' to %s.\n", host, handle);
     }
-    make_rand_str(s, 15);
+    make_rand_str(s, MAXPASSLEN);
     set_user(&USERENTRY_PASS, u2, s);
 
-    make_rand_str(s2, 16);
+    make_rand_str(s2, MAXPASSLEN);
     set_user(&USERENTRY_SECPASS, u2, s2);
     dprintf(idx, "%s's initial password set to %s%s%s\n", handle, BOLD(idx), s, BOLD_END(idx));
     dprintf(idx, "%s's initial secpass set to %s%s%s\n", handle, BOLD(idx), s2, BOLD_END(idx));

+ 4 - 4
src/crypt.c

@@ -119,12 +119,12 @@ void encrypt_pass(char *s1, char *s2)
 {
   char *tmp = NULL;
 
-  if (strlen(s1) > 15)
-    s1[15] = 0;
+  if (strlen(s1) > MAXPASSLEN)
+    s1[MAXPASSLEN] = 0;
   tmp = encrypt_string(s1, s1);
   strcpy(s2, "+");
-  strncat(s2, tmp, 15);
-  s2[15] = 0;
+  strncat(s2, tmp, MAXPASSLEN);
+  s2[MAXPASSLEN] = 0;
   free(tmp);
 }
 

+ 3 - 0
src/eggdrop.h

@@ -30,6 +30,9 @@
 
 /* Handy string lengths */
 
+#define MAXPASSLEN      15
+#define PACKNAMELEN     40
+
 #define UHOSTMAX    291 + NICKMAX /* 32 (ident) + 3 (\0, !, @) + NICKMAX */
 #define DIRMAX		512	/* paranoia				*/
 #define BADHANDCHARS	"-,+*=:!.@#;$%&"

+ 4 - 10
src/makesettings.c

@@ -1,3 +1,4 @@
+#include "common.h"
 #include <string.h>
 #include <stdio.h>
 #include <ctype.h>
@@ -15,19 +16,12 @@ char *cfgfile = NULL;
 
 
 #define LISTSEPERATORS  ",=:; "
-#define BADNICKCHARS  ",+*=:!.@#;$%&"
 #define SWITCHMETA    "+-"
-#define HANDLEN         9
-#define NICKMAX         32
-#define UHOSTMAX        160
-#define MAXPASSLEN      25
-#define NETKEYLEN       33
-#define PACKNAMELEN     40
 
 struct cfg_struct {
-  char packname[PACKNAMELEN];
-  char shellhash[33];
-  char bdhash[33];
+  char packname[PACKNAMELEN + 1];
+  char shellhash[MD5_HASH_LENGTH + 1];
+  char bdhash[MD5_HASH_LENGTH + 1];
   char dccprefix[2];
   char *owners;
   char *hubs;

+ 3 - 3
src/mod/irc.mod/cmdsirc.c

@@ -1475,7 +1475,7 @@ static void cmd_adduser(struct userrec *u, int idx, char *par)
   char *nick = NULL, *hand = NULL;
   struct chanset_t *chan = NULL;
   memberlist *m = NULL;
-  char s[UHOSTLEN] = "", s1[UHOSTLEN] = "", s2[16] = "", s3[17] = "", tmp[50] = "";
+  char s[UHOSTLEN] = "", s1[UHOSTLEN] = "", s2[MAXPASSLEN + 1] = "", s3[MAXPASSLEN + 1] = "", tmp[50] = "";
   int atr = u ? u->flags : 0;
   int statichost = 0;
   char *p1 = s1;
@@ -1556,10 +1556,10 @@ static void cmd_adduser(struct userrec *u, int idx, char *par)
     u = get_user_by_handle(userlist, hand);
     sprintf(tmp, "%li %s", now, dcc[idx].nick);
     set_user(&USERENTRY_ADDED, u, tmp);
-    make_rand_str(s2, 15);
+    make_rand_str(s2, MAXPASSLEN);
     set_user(&USERENTRY_PASS, u, s2);
 
-    make_rand_str(s3, 16);
+    make_rand_str(s3, MAXPASSLEN);
     set_user(&USERENTRY_SECPASS, u, s3);
 
     dprintf(idx, "Added [%s]%s with no flags.\n", hand, p1);

+ 2 - 2
src/mod/irc.mod/msgcmds.c

@@ -37,8 +37,8 @@ static int msg_pass(char *nick, char *host, struct userrec *u, char *par)
   } else {
     new = old;
   }
-  if (strlen(new) > 16)
-    new[16] = 0;
+  if (strlen(new) > MAXPASSLEN)
+    new[MAXPASSLEN] = 0;
 
   if (!goodpass(new, 0, nick)) {
     putlog(LOG_CMDS, "*", "(%s!%s) !%s! \002!\002PASS...", nick, host, u->handle);

+ 2 - 2
src/userent.c

@@ -543,8 +543,8 @@ int pass_set(struct userrec *u, struct user_entry *e, void *buf)
   else {
     unsigned char *p = (unsigned char *) pass;
 
-    if (strlen(pass) > 15)
-      pass[15] = 0;
+    if (strlen(pass) > MAXPASSLEN)
+      pass[MAXPASSLEN] = 0;
     while (*p) {
       if ((*p <= 32) || (*p == 127))
 	*p = '?';

+ 3 - 3
src/userrec.c

@@ -241,7 +241,7 @@ struct userrec *get_user_by_host(char *host)
  */
 int u_pass_match(struct userrec *u, char *in)
 {
-  char *cmp = NULL, new[32] = "", pass[16] = "";
+  char *cmp = NULL, new[32] = "", pass[MAXPASSLEN + 1] = "";
 
   if (!u)
     return 0;
@@ -257,8 +257,8 @@ int u_pass_match(struct userrec *u, char *in)
     if (!strcmp(cmp, pass))
       return 1;
   } else {
-    if (strlen(pass) > 15)
-      pass[15] = 0;
+    if (strlen(pass) > MAXPASSLEN)
+      pass[MAXPASSLEN] = 0;
     encrypt_pass(pass, new);
     if (!strcmp(cmp, new))
       return 1;