Преглед изворни кода

* Fix crypted password getting truncated on share

Bryan Drewery пре 16 година
родитељ
комит
2aea6f7a09
1 измењених фајлова са 9 додато и 8 уклоњено
  1. 9 8
      src/userent.c

+ 9 - 8
src/userent.c

@@ -576,17 +576,18 @@ static bool pass_set(struct userrec *u, struct user_entry *e, void *buf)
   else {
     unsigned char *p = (unsigned char *) pass;
 
-    if (strlen(pass) > MAXPASSLEN)
-      pass[MAXPASSLEN] = 0;
-    while (*p) {
-      if ((*p <= 32) || (*p == 127))
-	*p = '?';
-      p++;
-    }
     if (u->bot || (pass[0] == '+'))
       newpass = strdup(pass);
-    else
+    else {
+      if (strlen(pass) > MAXPASSLEN)
+        pass[MAXPASSLEN] = 0;
+      while (*p) {
+        if ((*p <= 32) || (*p == 127))
+          *p = '?';
+        p++;
+      }
       newpass = salted_sha1(pass);
+    }
     e->u.extra = strdup(newpass);
   }
   if (!noshare)