From 5662ba160bd5494dd8a8f01130010727ebe0bee6 Mon Sep 17 00:00:00 2001 From: "Victor M. Alvarez" Date: Fri, 16 Apr 2021 10:03:14 +0200 Subject: [PATCH] Allow the "match" function to accept pid=0 as an argument. Because the function was initializing pid as 0, when the user passed pid=0 as an argument it was indistinguishable from not pid being passed at all. Closes https://github.com/VirusTotal/yara/issues/1480 --- yara-python.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/yara-python.c b/yara-python.c index d07bdbd..2d88b9b 100644 --- a/yara-python.c +++ b/yara-python.c @@ -1499,7 +1499,7 @@ static PyObject* Rules_match( char* filepath = NULL; Py_buffer data = {0}; - int pid = 0; + int pid = -1; int timeout = 0; int error = ERROR_SUCCESS; int fast_mode = 0; @@ -1535,7 +1535,7 @@ static PyObject* Rules_match( &callback_data.which, &callback_data.warnings_callback)) { - if (filepath == NULL && data.buf == NULL && pid == 0) + if (filepath == NULL && data.buf == NULL && pid == -1) { return PyErr_Format( PyExc_TypeError, @@ -1646,7 +1646,7 @@ static PyObject* Rules_match( Py_END_ALLOW_THREADS } - else if (pid != 0) + else if (pid != -1) { callback_data.matches = PyList_New(0); @@ -1686,7 +1686,7 @@ static PyObject* Rules_match( { handle_error(error, filepath); } - else if (pid != 0) + else if (pid != -1) { handle_error(error, ""); }