Ticket #228: jabberd2-2.2.0-crypt.patch
| File jabberd2-2.2.0-crypt.patch, 1.0 KB (added by shino, 5 months ago) |
|---|
-
storage/authreg_mysql.c
old new 20 20 21 21 /* this module talks to a MySQL server via libmysqlclient */ 22 22 23 #define _XOPEN_SOURCE 23 24 #include "c2s.h" 24 25 #include <mysql.h> 25 26 … … 29 30 30 31 enum mysql_pws_crypt { MPC_PLAIN, MPC_CRYPT }; 31 32 33 static char salter[] = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ./"; 34 32 35 typedef struct mysqlcontext_st { 33 36 MYSQL * conn; 34 37 char * sql_create; … … 173 176 snprintf(iuser, MYSQL_LU+1, "%s", username); 174 177 snprintf(irealm, MYSQL_LR+1, "%s", realm); 175 178 179 if (ctx->password_type == MPC_CRYPT) { 180 char salt[12] = "$1$"; 181 int i; 182 183 srand(time(0)); 184 for(i=0; i<8; i++) 185 salt[3+i] = salter[rand()%64]; 186 salt[11] = '\0'; 187 strcpy(password, crypt(password, salt)); 188 } 189 176 190 password[256]= '\0'; 177 191 178 192 mysql_real_escape_string(conn, euser, iuser, strlen(iuser));
