[glib/new-gsettings] add safety against corrupt gvdb files
- From: Ryan Lortie <ryanl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib/new-gsettings] add safety against corrupt gvdb files
- Date: Wed, 14 Apr 2010 23:46:13 +0000 (UTC)
commit 178225a04a70093e895a7572d63214df8188fdb0
Author: Ryan Lortie <desrt desrt ca>
Date: Wed Apr 14 19:42:26 2010 -0400
add safety against corrupt gvdb files
gio/gvdb/gvdb-reader.c | 9 +++++----
1 files changed, 5 insertions(+), 4 deletions(-)
---
diff --git a/gio/gvdb/gvdb-reader.c b/gio/gvdb/gvdb-reader.c
index 5f80d1f..c4ea31b 100644
--- a/gio/gvdb/gvdb-reader.c
+++ b/gio/gvdb/gvdb-reader.c
@@ -224,6 +224,7 @@ gvdb_table_lookup (GvdbTable *file,
{
guint32 hash_value = 5381;
guint key_length;
+ guint32 bucket;
guint32 lastno;
guint32 itemno;
@@ -236,11 +237,11 @@ gvdb_table_lookup (GvdbTable *file,
if (!gvdb_table_bloom_filter (file, hash_value))
return NULL;
- itemno = file->hash_buckets[hash_value % file->n_buckets];
+ bucket = hash_value % file->n_buckets;
+ itemno = file->hash_buckets[bucket];
- if (hash_value % file->n_buckets != file->n_buckets - 1)
- lastno = file->hash_buckets[hash_value % file->n_buckets + 1];
- else
+ if (bucket == file->n_buckets - 1 ||
+ (lastno = file->hash_buckets[bucket + 1]) > file->n_hash_items)
lastno = file->n_hash_items;
while G_LIKELY (itemno < lastno)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]