Răsfoiți Sursa

* Set the first character of the salted pass to +

Bryan Drewery 17 ani în urmă
părinte
comite
aeda064846
2 a modificat fișierele cu 3 adăugiri și 3 ștergeri
  1. 2 2
      src/crypt.c
  2. 1 1
      src/userrec.c

+ 2 - 2
src/crypt.c

@@ -153,9 +153,9 @@ char *encrypt_pass(struct userrec *u, char *in, const char *saltin)
   simple_snprintf(buf, sizeof(buf), STR("%s%s"), salt, in);
   tmp = SHA1(buf);
 
-  ret_size = (sizeof(salt) - 1) + 1 + SHA_HASH_LENGTH + 1;
+  ret_size = 1 + (sizeof(salt) - 1) + 1 + SHA_HASH_LENGTH + 1;
   ret = (char *) my_calloc(1, ret_size);
-  simple_snprintf(ret, ret_size, STR("%s$%s"), salt, tmp);
+  simple_snprintf(ret, ret_size, STR("+%s$%s"), salt, tmp);
 
   /* Wipe cleartext pass from sha1 buffers/tmp */
   SHA1(NULL);

+ 1 - 1
src/userrec.c

@@ -343,7 +343,7 @@ int u_pass_match(struct userrec *u, char *in)
     if (strlen(pass) > MAXPASSLEN)
       pass[MAXPASSLEN] = 0;
     /* Pass the salted pass in so the same salt can be used */
-    char* newpass = encrypt_pass(u, pass, cmp);
+    char* newpass = encrypt_pass(u, pass, &cmp[1]);
     if (!strcmp(cmp, newpass)) {
       free(newpass);
       return 1;