[Forensics-changes] [yara] 117/415: Fix segfault when inspecting attributes of 'Rules' or 'Match' objects (issue 32)

Hilko Bengen bengen at moszumanska.debian.org
Thu Apr 3 05:42:52 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 34b7a291e7e26ddd1bc04bf059dfcec513f22d0c
Author: Victor M. Alvarez <plusvic at gmail.com>
Date:   Thu Dec 22 17:40:49 2011 +0000

    Fix segfault when inspecting attributes of 'Rules' or 'Match' objects (issue 32)
---
 yara-python/yara-python.c | 32 ++++++--------------------------
 1 file changed, 6 insertions(+), 26 deletions(-)

diff --git a/yara-python/yara-python.c b/yara-python/yara-python.c
index 4bfc517..ae64f0b 100644
--- a/yara-python/yara-python.c
+++ b/yara-python/yara-python.c
@@ -77,7 +77,6 @@ typedef struct {
 
 static PyObject * Match_repr(PyObject *self);
 static PyObject * Match_getattro(PyObject *self, PyObject *name);
-static int Match_compare(PyObject *self, PyObject *other);
 static PyObject * Match_richcompare(PyObject *self, PyObject *other, int op);
 static long Match_hash(PyObject *self);
 static void Match_dealloc(PyObject *self);
@@ -227,31 +226,6 @@ static PyObject * Match_richcompare(PyObject *self, PyObject *other, int op)
 
 }
 
-static int Match_compare(PyObject *self, PyObject *other)
-{
-    int result;
-
-    Match *a = (Match *) self;
-    Match *b = (Match *) other;
-
-    if(PyObject_TypeCheck(other, &Match_Type))
-    {
-        result = PyObject_RichCompareBool(a->rule, b->rule, Py_EQ);
-
-        if (result == 0)
-        {
-            result = PyObject_RichCompareBool(a->ns, b->ns, Py_EQ);
-        }
-    }
-    else
-    {
-        result = -1;
-        PyErr_BadArgument();
-    }
-
-    return result;
-  
-}
 
 static long Match_hash(PyObject *self)
 {
@@ -952,6 +926,12 @@ MOD_INIT(yara)
     YaraSyntaxError = Py_BuildValue("s", "yara.SyntaxError");
 #endif
 
+    if (PyType_Ready(&Rules_Type) < 0)
+        return MOD_ERROR_VAL;
+        
+    if (PyType_Ready(&Match_Type) < 0)
+        return MOD_ERROR_VAL;
+
     PyModule_AddObject(m, "Error", YaraError);
     PyModule_AddObject(m, "SyntaxError", YaraSyntaxError);
     

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