summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOndrej Kos <okos@redhat.com>2013-04-03 12:30:04 +0200
committerJakub Hrozek <jhrozek@redhat.com>2013-04-04 23:57:36 +0200
commit736ccbe7930f443d7d381d93d8cf89665345f36a (patch)
tree8849df8cd2d9c00f56051c714bd4af1e9d65b580
parentbba9bb80671636886206f74549705329c42e4bcc (diff)
downloadding-libs-736ccbe7930f443d7d381d93d8cf89665345f36a.zip
ding-libs-736ccbe7930f443d7d381d93d8cf89665345f36a.tar.gz
ding-libs-736ccbe7930f443d7d381d93d8cf89665345f36a.tar.xz
DHASH: Check before dereferencing
https://fedorahosted.org/sssd/ticket/1858
-rw-r--r--dhash/dhash.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/dhash/dhash.c b/dhash/dhash.c
index 8f7ea2d..72709af 100644
--- a/dhash/dhash.c
+++ b/dhash/dhash.c
@@ -768,12 +768,13 @@ unsigned long hash_count(hash_table_t *table)
int hash_keys(hash_table_t *table, unsigned long *count_arg, hash_key_t **keys_arg)
{
- unsigned long count = table->entry_count;
+ unsigned long count;
hash_key_t *keys;
hash_keys_callback_data_t data;
if (!table) return HASH_ERROR_BAD_TABLE;
+ count = table->entry_count;
if (count == 0) {
*count_arg = 0;
*keys_arg = NULL;
@@ -799,12 +800,13 @@ int hash_keys(hash_table_t *table, unsigned long *count_arg, hash_key_t **keys_a
int hash_values(hash_table_t *table, unsigned long *count_arg, hash_value_t **values_arg)
{
- unsigned long count = table->entry_count;
+ unsigned long count;
hash_value_t *values;
hash_values_callback_data_t data;
if (!table) return HASH_ERROR_BAD_TABLE;
+ count = table->entry_count;
if (count == 0) {
*count_arg = 0;
*values_arg = NULL;
@@ -843,12 +845,13 @@ static bool hash_entries_callback(hash_entry_t *item, void *user_data)
int hash_entries(hash_table_t *table, unsigned long *count_arg, hash_entry_t **entries_arg)
{
- unsigned long count = table->entry_count;
+ unsigned long count;
hash_entry_t *entries;
hash_entries_callback_data_t data;
if (!table) return HASH_ERROR_BAD_TABLE;
+ count = table->entry_count;
if (count == 0) {
*count_arg = 0;
*entries_arg = NULL;