diff options
| author | Wayne Davison <wayned@samba.org> | 2010-06-26 11:32:14 -0700 |
|---|---|---|
| committer | Wayne Davison <wayned@samba.org> | 2010-06-26 11:32:14 -0700 |
| commit | b384d71e53e6f4eed3cb1811551773285f6b0a69 (patch) | |
| tree | e2dfea22358aea1f0d2ab3b0f5b9c6abd5e6c949 | |
| parent | 11f4f34ed96eafd0ff9e1d5813e5476790a4b6e9 (diff) | |
| download | android_external_rsync-b384d71e53e6f4eed3cb1811551773285f6b0a69.tar.gz android_external_rsync-b384d71e53e6f4eed3cb1811551773285f6b0a69.tar.bz2 android_external_rsync-b384d71e53e6f4eed3cb1811551773285f6b0a69.zip | |
Make sure that the code doesn't try to use an illegal key.
| -rw-r--r-- | hashtable.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/hashtable.c b/hashtable.c index ed29ee91..0524e24b 100644 --- a/hashtable.c +++ b/hashtable.c @@ -41,7 +41,7 @@ struct hashtable *hashtable_create(int size, int key64) tbl->size = size; tbl->entries = 0; tbl->node_size = node_size; - tbl->key64 = key64; + tbl->key64 = key64 ? 1 : 0; return tbl; } @@ -60,6 +60,11 @@ void *hashtable_find(struct hashtable *tbl, int64 key, int allocate_if_missing) struct ht_int32_node *node; uint32 ndx; + if (key64 ? key == 0 : (int32)key == 0) { + rprintf(FERROR, "Internal hashtable error: illegal key supplied!\n"); + exit_cleanup(RERR_MESSAGEIO); + } + if (allocate_if_missing && tbl->entries > HASH_LOAD_LIMIT(tbl->size)) { void *old_nodes = tbl->nodes; int size = tbl->size * 2; @@ -142,7 +147,7 @@ void *hashtable_find(struct hashtable *tbl, int64 key, int allocate_if_missing) if (key64) ((struct ht_int64_node*)node)->key = key; else - node->key = key; + node->key = (int32)key; tbl->entries++; return node; } |
