chunk_to_hex() adaptations

This commit is contained in:
Andreas Steffen
2008-04-25 06:39:41 +00:00
parent 5e6bbf4f77
commit 36fecdb8a3
2 changed files with 14 additions and 15 deletions
+4 -4
View File
@@ -45,7 +45,7 @@ struct private_storage_t {
static int login(private_storage_t *this, char *username, char *password)
{
hasher_t *hasher;
chunk_t hash, data;
chunk_t hash, data, hex_str;
size_t username_len, password_len;
int uid = 0;
char *str;
@@ -65,18 +65,18 @@ static int login(private_storage_t *this, char *username, char *password)
memcpy(data.ptr + username_len, password, password_len);
hasher->get_hash(hasher, data, hash.ptr);
hasher->destroy(hasher);
str = chunk_to_hex(hash, FALSE);
hex_str = chunk_to_hex(hash, NULL, FALSE);
enumerator = this->db->query(this->db,
"SELECT oid FROM users WHERE username = ? AND password = ?;",
DB_TEXT, username, DB_TEXT, str,
DB_TEXT, username, DB_TEXT, hex_str.ptr,
DB_INT);
if (enumerator)
{
enumerator->enumerate(enumerator, &uid);
enumerator->destroy(enumerator);
}
free(str);
free(hex_str.ptr);
return uid;
}