[Forensics-changes] [yara] 70/415: Fixed issue with reserved keyword "namespace" on C++ compilers

Hilko Bengen bengen at moszumanska.debian.org
Thu Apr 3 05:42:46 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 4b4567b88f67e5baf397c8ea97bce6940e2a398b
Author: Victor M. Alvarez <plusvic at gmail.com>
Date:   Tue Jan 18 16:43:28 2011 +0000

    Fixed issue with reserved keyword "namespace" on C++ compilers
---
 libyara/ast.c             | 10 +++++-----
 libyara/ast.h             |  2 +-
 libyara/libyara.c         |  8 ++++----
 libyara/yara.h            |  6 +++---
 yara-python/yara-python.c | 30 +++++++++++++++---------------
 5 files changed, 28 insertions(+), 28 deletions(-)

diff --git a/libyara/ast.c b/libyara/ast.c
index c4964fa..05494b8 100644
--- a/libyara/ast.c
+++ b/libyara/ast.c
@@ -25,14 +25,14 @@ GNU General Public License for more details.
 
 #define todigit(x)  ((x) >='A'&& (x) <='F')? ((unsigned char) (x - 'A' + 10)) : ((unsigned char) (x - '0'))
 
-RULE* lookup_rule(RULE_LIST* rules, const char* identifier, NAMESPACE* namespace)
+RULE* lookup_rule(RULE_LIST* rules, const char* identifier, NAMESPACE* ns)
 {
     RULE* rule = rules->head;
     
     while (rule != NULL)
     {
         if (strcmp(rule->identifier, identifier) == 0 &&
-			strcmp(rule->namespace->name, namespace->name) == 0)
+			strcmp(rule->ns->name, ns->name) == 0)
         {
             return rule;
         }
@@ -150,20 +150,20 @@ int require_exe_file(TERM* term)
     }
 }
 
-int new_rule(RULE_LIST* rules, char* identifier, NAMESPACE* namespace, int flags, TAG* tag_list_head, META* meta_list_head, STRING* string_list_head, TERM* condition)
+int new_rule(RULE_LIST* rules, char* identifier, NAMESPACE* ns, int flags, TAG* tag_list_head, META* meta_list_head, STRING* string_list_head, TERM* condition)
 {
     RULE* new_rule;
     
     int result = ERROR_SUCCESS;
     
-    if (lookup_rule(rules, identifier, namespace) == NULL)  /* do not allow rules with the same identifier */
+    if (lookup_rule(rules, identifier, ns) == NULL)  /* do not allow rules with the same identifier */
     {
         new_rule = (RULE*) yr_malloc(sizeof(RULE));
     
         if (new_rule != NULL)
         {
             new_rule->identifier = identifier;
-			new_rule->namespace = namespace;
+			new_rule->ns = ns;
             new_rule->flags = flags;
 			new_rule->tag_list_head = tag_list_head;
             new_rule->meta_list_head = meta_list_head;
diff --git a/libyara/ast.h b/libyara/ast.h
index 4a4a274..7367b53 100644
--- a/libyara/ast.h
+++ b/libyara/ast.h
@@ -162,7 +162,7 @@ typedef struct _TERM_EXTERNAL_STRING_OPERATION
 
 
 
-int new_rule(RULE_LIST* rules, char* identifier, NAMESPACE* namespace, int flags, TAG* tag_list_head, META* meta_list_head, STRING* string_list_head, TERM* condition);
+int new_rule(RULE_LIST* rules, char* identifier, NAMESPACE* ns, int flags, TAG* tag_list_head, META* meta_list_head, STRING* string_list_head, TERM* condition);
 
 int new_string(YARA_CONTEXT* context, char* identifier, SIZED_STRING* charstr, int flags, STRING** string);
 
diff --git a/libyara/libyara.c b/libyara/libyara.c
index 0dc6d34..4c92285 100644
--- a/libyara/libyara.c
+++ b/libyara/libyara.c
@@ -194,13 +194,13 @@ void yr_destroy_context(YARA_CONTEXT* context)
 }
 
 
-NAMESPACE* yr_create_namespace(YARA_CONTEXT* context, const char* namespace)
+NAMESPACE* yr_create_namespace(YARA_CONTEXT* context, const char* name)
 {
 	NAMESPACE* ns = yr_malloc(sizeof(NAMESPACE));
 	
 	if (ns != NULL)
 	{
-		ns->name = yr_strdup(namespace);
+		ns->name = yr_strdup(name);
 		ns->global_rules_satisfied = FALSE;
 		ns->next = context->namespaces;
 		context->namespaces = ns;
@@ -445,7 +445,7 @@ int yr_scan_mem_blocks(MEMORY_BLOCK* block, YARA_CONTEXT* context, YARACALLBACK
     		}
     		else
     		{
-                rule->namespace->global_rules_satisfied = FALSE;
+                rule->ns->global_rules_satisfied = FALSE;
     		}
     		
     		if (!(rule->flags & RULE_FLAGS_PRIVATE))
@@ -471,7 +471,7 @@ int yr_scan_mem_blocks(MEMORY_BLOCK* block, YARA_CONTEXT* context, YARACALLBACK
 		   evaluated due to some global rule unsatisfied in it's namespace
 		*/
 		
-		if (rule->flags & RULE_FLAGS_GLOBAL || rule->flags & RULE_FLAGS_PRIVATE || !rule->namespace->global_rules_satisfied)  
+		if (rule->flags & RULE_FLAGS_GLOBAL || rule->flags & RULE_FLAGS_PRIVATE || !rule->ns->global_rules_satisfied)  
 		{
 			rule = rule->next;
 			continue;
diff --git a/libyara/yara.h b/libyara/yara.h
index c71e1e7..21568f5 100644
--- a/libyara/yara.h
+++ b/libyara/yara.h
@@ -205,7 +205,7 @@ typedef struct _RULE
 {
     char*           identifier;
     int             flags;
-	NAMESPACE*		namespace;
+	NAMESPACE*		ns;
     STRING*         string_list_head;
 	TAG*			tag_list_head;
     META*           meta_list_head;
@@ -291,7 +291,7 @@ typedef struct _YARA_CONTEXT
 } YARA_CONTEXT;
 
 
-RULE*                   lookup_rule(RULE_LIST* rules, const char* identifier, NAMESPACE* namespace);
+RULE*                   lookup_rule(RULE_LIST* rules, const char* identifier, NAMESPACE* ns);
 STRING*                 lookup_string(STRING* string_list_head, const char* identifier);
 TAG*                    lookup_tag(TAG* tag_list_head, const char* identifier);
 META*                   lookup_meta(META* meta_list_head, const char* identifier);
@@ -304,7 +304,7 @@ void                yr_destroy_context(YARA_CONTEXT* context);
 
 int                 yr_calculate_rules_weight(YARA_CONTEXT* context);
 
-NAMESPACE*			yr_create_namespace(YARA_CONTEXT* context, const char* namespace);
+NAMESPACE*			yr_create_namespace(YARA_CONTEXT* context, const char* name);
 
 int                 yr_set_external_integer(YARA_CONTEXT* context, const char* identifier, size_t value);
 int                 yr_set_external_boolean(YARA_CONTEXT* context, const char* identifier, int value);
diff --git a/yara-python/yara-python.c b/yara-python/yara-python.c
index 9e23c4e..691b841 100644
--- a/yara-python/yara-python.c
+++ b/yara-python/yara-python.c
@@ -105,7 +105,7 @@ typedef struct {
     
     PyObject_HEAD
 	PyObject* rule;
-	PyObject* namespace;
+	PyObject* ns;
     PyObject* tags;
     PyObject* meta;
     PyObject* strings;
@@ -123,7 +123,7 @@ static void Match_dealloc(PyObject *self);
 
 static PyMemberDef Match_members[] = {
 	{"rule", T_OBJECT_EX, offsetof(Match, rule), READONLY, "Name of the matching rule"},
-	{"namespace", T_OBJECT_EX, offsetof(Match, namespace), READONLY, "Namespace of the matching rule"},
+	{"namespace", T_OBJECT_EX, offsetof(Match, ns), READONLY, "Namespace of the matching rule"},
     {"tags", T_OBJECT_EX, offsetof(Match, tags), READONLY, "List of tags associated to the rule"},
     {"meta", T_OBJECT_EX, offsetof(Match, meta), READONLY, "Dictionary with metadata associated to the rule"},
     {"strings", T_OBJECT_EX, offsetof(Match, strings), READONLY, "Dictionary with offsets and strings that matched the file"},
@@ -178,7 +178,7 @@ static PyTypeObject Match_Type = {
 };
 
 
-static PyObject * Match_NEW(const char* rule, const char* namespace, PyObject* tags, PyObject* meta, PyObject* strings)
+static PyObject * Match_NEW(const char* rule, const char* ns, PyObject* tags, PyObject* meta, PyObject* strings)
 { 
     Match* object;
     
@@ -187,7 +187,7 @@ static PyObject * Match_NEW(const char* rule, const char* namespace, PyObject* t
     if (object != NULL)
     {
 		object->rule = PyString_FromString(rule);
-		object->namespace = PyString_FromString(namespace);
+		object->ns = PyString_FromString(ns);
         object->tags = tags;
         object->meta = meta;
         object->strings = strings;
@@ -201,7 +201,7 @@ static void Match_dealloc(PyObject *self)
     Match *object = (Match *) self;
      
 	Py_DECREF(object->rule); 
-	Py_DECREF(object->namespace);
+	Py_DECREF(object->ns);
     Py_DECREF(object->tags);
     Py_DECREF(object->meta);  
     Py_DECREF(object->strings);
@@ -234,7 +234,7 @@ static int Match_compare(PyObject *self, PyObject *other)
 		
 		if (result == 0)
 		{
-			result = PyObject_Compare(a->namespace, b->namespace);
+			result = PyObject_Compare(a->ns, b->ns);
 		}
 	}
 	else
@@ -251,7 +251,7 @@ static long Match_hash(PyObject *self)
 {
 	Match *match = (Match *) self;
 	
-	return PyObject_Hash(match->rule) + PyObject_Hash(match->namespace);
+	return PyObject_Hash(match->rule) + PyObject_Hash(match->ns);
 }
 
 //////////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -515,7 +515,7 @@ int callback(RULE* rule, void* data)
     
     PyList_Sort(stringlist);
        
-    match = Match_NEW(rule->identifier, rule->namespace->name, taglist, metalist, stringlist);
+    match = Match_NEW(rule->identifier, rule->ns->name, taglist, metalist, stringlist);
     
     if (match != NULL)
     {       
@@ -666,7 +666,7 @@ static PyObject * yara_compile(PyObject *self, PyObject *args, PyObject *keyword
 
     char* filepath = NULL;
     char* source = NULL;
-	char* namespace = NULL;
+	char* ns = NULL;
 	    
     if (PyArg_ParseTupleAndKeywords(args, keywords, "|ssOOOOO", kwlist, &filepath, &source, &file, &filepaths_dict, &sources_dict, &includes, &externals))
     {      
@@ -735,11 +735,11 @@ static PyObject * yara_compile(PyObject *self, PyObject *args, PyObject *keyword
 				while (PyDict_Next(sources_dict, &pos, &key, &value)) 
 				{
 					source = PyString_AsString(value);
-					namespace = PyString_AsString(key);
+					ns = PyString_AsString(key);
 					
-					if (source != NULL && namespace != NULL)
+					if (source != NULL && ns != NULL)
 					{
-		                context->current_namespace = yr_create_namespace(context, namespace);
+		                context->current_namespace = yr_create_namespace(context, ns);
 
 						result = Rules_new_from_string(source, result, context);
 					}
@@ -762,15 +762,15 @@ static PyObject * yara_compile(PyObject *self, PyObject *args, PyObject *keyword
 				while (PyDict_Next(filepaths_dict, &pos, &key, &value)) 
 				{
 					filepath = PyString_AsString(value);
-					namespace = PyString_AsString(key);
+					ns = PyString_AsString(key);
 					
-					if (filepath != NULL && namespace != NULL)
+					if (filepath != NULL && ns != NULL)
 					{
 						fh = fopen(filepath, "r");
             
             			if (fh != NULL)
             			{
-            			    context->current_namespace = yr_create_namespace(context, namespace);
+            			    context->current_namespace = yr_create_namespace(context, ns);
             			
                 			result = Rules_new_from_file(fh, filepath, result, context);
                 			fclose(fh);

-- 
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