Skip to content

Commit

Permalink
Allow the "match" function to accept pid=0 as an argument.
Browse files Browse the repository at this point in the history
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 VirusTotal/yara#1480
  • Loading branch information
plusvic committed Apr 16, 2021
1 parent 1a159c3 commit 5662ba1
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions yara-python.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -1686,7 +1686,7 @@ static PyObject* Rules_match(
{
handle_error(error, filepath);
}
else if (pid != 0)
else if (pid != -1)
{
handle_error(error, "<proc>");
}
Expand Down

0 comments on commit 5662ba1

Please sign in to comment.