Fixed possible NULL pointer dereference and out-of-bounds read in user hashtable comparison function.

This commit is contained in:
Markus Makela
2015-08-17 07:23:24 +03:00
parent 458598141b
commit b26b3eff6b

View File

@ -37,18 +37,6 @@
* @endverbatim
*/
/**
* The hash function we user for storing users.
*
* @param key The key value, i.e. username
* @return The hash key
*/
static int
user_hash(char *key)
{
return (*key + *(key + 1));
}
/**
* Allocate a new users table
*
@ -65,7 +53,7 @@ USERS *rval;
return NULL;
}
if ((rval->data = hashtable_alloc(USERS_HASHTABLE_DEFAULT_SIZE, user_hash, strcmp)) == NULL)
if ((rval->data = hashtable_alloc(USERS_HASHTABLE_DEFAULT_SIZE, simple_str_hash, strcmp)) == NULL)
{
skygw_log_write(LE,"[%s:%d] Error: Memory allocation failed.",__FUNCTION__,__LINE__);
free(rval);