[Forensics-changes] [yara] 103/160: Fix issues in yara-python while compiling in Windows

Hilko Bengen bengen at moszumanska.debian.org
Sat Jul 1 10:29:23 UTC 2017


This is an automated email from the git hooks/post-receive script.

bengen pushed a commit to annotated tag v3.4.0
in repository yara.

commit 97c46f31c61f54259739bcf0bb6f57169384b690
Author: Victor M. Alvarez <plusvic at gmail.com>
Date:   Tue May 5 12:29:39 2015 +0200

    Fix issues in yara-python while compiling in Windows
---
 yara-python/yara-python.c | 20 ++++++++++++--------
 1 file changed, 12 insertions(+), 8 deletions(-)

diff --git a/yara-python/yara-python.c b/yara-python/yara-python.c
index 5378944..4ae353f 100644
--- a/yara-python/yara-python.c
+++ b/yara-python/yara-python.c
@@ -604,7 +604,9 @@ static size_t flo_read(
     size_t count,
     void* user_data)
 {
-  for (int i = 0; i < count; i++)
+  size_t i;
+
+  for (i = 0; i < count; i++)
   {
     PyGILState_STATE gil_state = PyGILState_Ensure();
 
@@ -622,10 +624,10 @@ static size_t flo_read(
 
       Py_DECREF(bytes);
 
-      if (result == -1 || len < size)
+      if (result == -1 || (size_t) len < size)
         return i;
 
-      memcpy(ptr + i * size, buffer, size);
+      memcpy((char*) ptr + i * size, buffer, size);
     }
     else
     {
@@ -645,12 +647,14 @@ static size_t flo_write(
     size_t count,
     void* user_data)
 {
-  for (int i = 0; i < count; i++)
+  size_t i;
+
+  for (i = 0; i < count; i++)
   {
     PyGILState_STATE gil_state = PyGILState_Ensure();
 
     PyObject* result = PyObject_CallMethod(
-        (PyObject*) user_data, "write", "s#", ptr + i * size, size);
+        (PyObject*) user_data, "write", "s#", (char*) ptr + i * size, size);
 
     PyGILState_Release(gil_state);
 
@@ -1656,6 +1660,8 @@ static PyObject * yara_load(
 {
   Rules* rules = PyObject_NEW(Rules, &Rules_Type);
   PyObject* param;
+  YR_EXTERNAL_VARIABLE* external;
+  int error;
 
   if (rules == NULL)
     return PyErr_NoMemory();
@@ -1667,8 +1673,6 @@ static PyObject * yara_load(
           "load() takes 1 argument");
   }
 
-  int error;
-
   if (PY_STRING_CHECK(param))
   {
     char* filepath = PY_STRING_TO_C(param);
@@ -1701,7 +1705,7 @@ static PyObject * yara_load(
       "load() expects either a file path or a file-like object");
   }
 
-  YR_EXTERNAL_VARIABLE* external = rules->rules->externals_list_head;
+  external = rules->rules->externals_list_head;
   rules->iter_current_rule = rules->rules->rules_list_head;
 
   if (!EXTERNAL_VARIABLE_IS_NULL(external))

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