[gq-commit] gq/src dt_password.c,1.7,1.8
Status: Beta
Brought to you by:
sur5r
From: <sta...@us...> - 2002-07-12 17:59:52
|
Update of /cvsroot/gqclient/gq/src In directory usw-pr-cvs1:/tmp/cvs-serv25491 Modified Files: dt_password.c Log Message: * Got rid of all strcat and strcpy calls (TODO item) Index: dt_password.c =================================================================== RCS file: /cvsroot/gqclient/gq/src/dt_password.c,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** dt_password.c 9 Jul 2002 10:31:11 -0000 1.7 --- dt_password.c 12 Jul 2002 17:59:47 -0000 1.8 *************** *** 106,112 **** GString *salt; GByteArray *gb = g_byte_array_new(); ! unsigned char *password, rand[16]; ! gb = g_byte_array_set_size(gb, 64); password = (char*) g_malloc((len + 1) * sizeof(char)); --- 106,112 ---- GString *salt; GByteArray *gb = g_byte_array_new(); ! unsigned char *password, rand[16], cryptbuf[32]; ! /* gb = g_byte_array_set_size(gb, 64); */ password = (char*) g_malloc((len + 1) * sizeof(char)); *************** *** 122,128 **** salt->str[2] = 0; ! strcpy(gb->data, "{crypt}"); ! des_fcrypt(password, salt->str, gb->data + strlen(gb->data)); ! g_byte_array_set_size(gb, strlen(gb->data)); g_string_free(salt, TRUE); --- 122,131 ---- salt->str[2] = 0; ! g_byte_array_append(gb, "{crypt}", 7); ! ! /* strcpy(gb->data, "{crypt}"); */ ! des_fcrypt(password, salt->str, cryptbuf); ! /* gb->data + strlen(gb->data)); */ ! g_byte_array_append(gb, cryptbuf, strlen(cryptbuf)); g_string_free(salt, TRUE); *************** *** 142,151 **** b64_encode(b64, md5_out, MD5_DIGEST_LENGTH); ! gb = g_byte_array_set_size(gb, MD5_DIGEST_LENGTH + 10); ! strcpy(gb->data, "{MD5}"); ! strcat(gb->data, b64->str); ! g_byte_array_set_size(gb, strlen(gb->data)); g_string_free(b64, TRUE); --- 145,157 ---- b64_encode(b64, md5_out, MD5_DIGEST_LENGTH); ! g_byte_array_append(gb, "{MD5}", 5); ! g_byte_array_append(gb, b64->str, strlen(b64->str)); ! ! /* gb = g_byte_array_set_size(gb, MD5_DIGEST_LENGTH + 10); */ ! /* strcpy(gb->data, "{MD5}"); */ ! /* strcat(gb->data, b64->str); */ ! /* g_byte_array_set_size(gb, strlen(gb->data)); */ g_string_free(b64, TRUE); *************** *** 164,173 **** b64_encode(b64, sha_out, SHA_DIGEST_LENGTH); ! gb = g_byte_array_set_size(gb, SHA_DIGEST_LENGTH + 10); ! ! strcpy(gb->data, "{SHA}"); ! strcat(gb->data, b64->str); ! g_byte_array_set_size(gb, strlen(gb->data)); g_string_free(b64, TRUE); --- 170,181 ---- b64_encode(b64, sha_out, SHA_DIGEST_LENGTH); ! /* gb = g_byte_array_set_size(gb, SHA_DIGEST_LENGTH + 10); */ ! ! /* strcpy(gb->data, "{SHA}"); */ ! /* strcat(gb->data, b64->str); */ ! /* g_byte_array_set_size(gb, strlen(gb->data)); */ ! g_byte_array_append(gb, "{SHA}", 5); ! g_byte_array_append(gb, b64->str, strlen(b64->str)); g_string_free(b64, TRUE); *************** *** 196,205 **** b64_encode(b64, sha_out, sizeof(sha_out)); ! gb = g_byte_array_set_size(gb, SHA_DIGEST_LENGTH + 16); ! strcpy(gb->data, "{SSHA}"); ! strcat(gb->data, b64->str); ! g_byte_array_set_size(gb, strlen(gb->data)); g_string_free(b64, TRUE); --- 204,216 ---- b64_encode(b64, sha_out, sizeof(sha_out)); ! /* gb = g_byte_array_set_size(gb, SHA_DIGEST_LENGTH + 16); */ ! /* strcpy(gb->data, "{SSHA}"); */ ! /* strcat(gb->data, b64->str); */ ! /* g_byte_array_set_size(gb, strlen(gb->data)); */ ! ! g_byte_array_append(gb, "{SSHA}", 6); ! g_byte_array_append(gb, b64->str, strlen(b64->str)); g_string_free(b64, TRUE); *************** *** 227,236 **** b64_encode(b64, md5_out, sizeof(md5_out)); ! gb = g_byte_array_set_size(gb, MD5_DIGEST_LENGTH + 16); ! strcpy(gb->data, "{SMD5}"); ! strcat(gb->data, b64->str); ! g_byte_array_set_size(gb, strlen(gb->data)); g_string_free(b64, TRUE); --- 238,249 ---- b64_encode(b64, md5_out, sizeof(md5_out)); ! /* gb = g_byte_array_set_size(gb, MD5_DIGEST_LENGTH + 16); */ ! /* strcpy(gb->data, "{SMD5}"); */ ! /* strcat(gb->data, b64->str); */ ! /* g_byte_array_set_size(gb, strlen(gb->data)); */ ! g_byte_array_append(gb, "{SMD5}", 6); ! g_byte_array_append(gb, b64->str, strlen(b64->str)); g_string_free(b64, TRUE); |