[Forensics-changes] [yara] 197/415: Fix bug in hash tables
Hilko Bengen
bengen at moszumanska.debian.org
Thu Apr 3 05:43:04 UTC 2014
This is an automated email from the git hooks/post-receive script.
bengen pushed a commit to branch debian
in repository yara.
commit 48fc3c0a8dd08a1b40fb08b9c1f0fe5bc970fc2d
Author: Victor M. Alvarez <plusvic at gmail.com>
Date: Fri Jul 26 17:40:04 2013 +0000
Fix bug in hash tables
---
libyara/hash.c | 16 ++++++++++++++--
libyara/yara.h | 1 +
2 files changed, 15 insertions(+), 2 deletions(-)
diff --git a/libyara/hash.c b/libyara/hash.c
index c92f455..38add40 100644
--- a/libyara/hash.c
+++ b/libyara/hash.c
@@ -123,6 +123,8 @@ void yr_hash_table_destroy(
while (entry != NULL)
{
next_entry = entry->next;
+ if (entry->namespace != NULL)
+ yr_free(entry->namespace);
yr_free(entry->key);
yr_free(entry);
entry = next_entry;
@@ -152,8 +154,13 @@ void* yr_hash_table_lookup(
while (entry != NULL)
{
- if (strcmp(entry->key, key) == 0)
+ if (strcmp(entry->key, key) == 0 &&
+ (entry->namespace == namespace ||
+ strcmp(entry->namespace, namespace) == 0))
+ {
return entry->value;
+ }
+
entry = entry->next;
}
@@ -175,7 +182,6 @@ int yr_hash_table_add(
return ERROR_INSUFICIENT_MEMORY;
entry->key = yr_strdup(key);
- entry->value = value;
if (entry->key == NULL)
{
@@ -183,6 +189,12 @@ int yr_hash_table_add(
return ERROR_INSUFICIENT_MEMORY;
}
+ if (namespace != NULL)
+ entry->namespace = yr_strdup(namespace);
+ else
+ entry->namespace = NULL;
+
+ entry->value = value;
bucket_index = hash(0, key, strlen(key));
if (namespace != NULL)
diff --git a/libyara/yara.h b/libyara/yara.h
index 57859db..8b17dce 100644
--- a/libyara/yara.h
+++ b/libyara/yara.h
@@ -383,6 +383,7 @@ typedef struct _YARA_RULES_FILE_HEADER
typedef struct _HASH_TABLE_ENTRY
{
char* key;
+ char* namespace;
void* value;
struct _HASH_TABLE_ENTRY* next;
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/forensics/yara.git
More information about the forensics-changes
mailing list