Skip to content

Commit 5ab9688

Browse files
committed
Validate that "compile" function is not receiving too many arguments.
Closes VirusTotal#193
1 parent b072a2d commit 5ab9688

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

yara-python.c

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1560,7 +1560,6 @@ static PyObject* Rules_match(
15601560
int pid = -1;
15611561
int timeout = 0;
15621562
int error = ERROR_SUCCESS;
1563-
int fast_mode = 0;
15641563

15651564
PyObject* externals = NULL;
15661565
PyObject* fast = NULL;
@@ -2129,6 +2128,27 @@ static PyObject* yara_compile(
21292128
&error_on_warning,
21302129
&include_callback))
21312130
{
2131+
char num_args = 0;
2132+
2133+
if (filepath != NULL)
2134+
num_args++;
2135+
2136+
if (source != NULL)
2137+
num_args++;
2138+
2139+
if (file != NULL)
2140+
num_args++;
2141+
2142+
if (filepaths_dict != NULL)
2143+
num_args++;
2144+
2145+
if (sources_dict != NULL)
2146+
num_args++;
2147+
2148+
if (num_args > 1)
2149+
return PyErr_Format(
2150+
PyExc_TypeError,
2151+
"compile is receiving too many arguments");
21322152

21332153
error = yr_compiler_create(&compiler);
21342154

0 commit comments

Comments
 (0)