Skip to content

Commit df5ea5b

Browse files
kevin-haynieplusvic
authored andcommitted
Added max_match_data to set_config (VirusTotal#121)
1 parent b9b3d24 commit df5ea5b

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

yara-python.c

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1837,20 +1837,22 @@ static PyObject* yara_set_config(
18371837
* options present in yara/libyara.c yr_set_configuration(...) - ck
18381838
*/
18391839
static char *kwlist[] = {
1840-
"stack_size", "max_strings_per_rule", NULL};
1840+
"stack_size", "max_strings_per_rule", "max_match_data", NULL};
18411841

18421842
unsigned int stack_size = 0;
18431843
unsigned int max_strings_per_rule = 0;
1844+
unsigned int max_match_data = 0;
18441845

18451846
int error = 0;
18461847

18471848
if (PyArg_ParseTupleAndKeywords(
18481849
args,
18491850
keywords,
1850-
"|II",
1851+
"|III",
18511852
kwlist,
18521853
&stack_size,
1853-
&max_strings_per_rule))
1854+
&max_strings_per_rule,
1855+
&max_match_data))
18541856
{
18551857
if (stack_size != 0)
18561858
{
@@ -1871,6 +1873,16 @@ static PyObject* yara_set_config(
18711873
if (error != ERROR_SUCCESS)
18721874
return handle_error(error, NULL);
18731875
}
1876+
1877+
if (max_match_data != 0)
1878+
{
1879+
error = yr_set_configuration(
1880+
YR_CONFIG_MAX_MATCH_DATA,
1881+
&max_match_data);
1882+
1883+
if (error != ERROR_SUCCESS)
1884+
return handle_error(error, NULL);
1885+
}
18741886
}
18751887

18761888
Py_RETURN_NONE;
@@ -2309,7 +2321,7 @@ static PyMethodDef yara_methods[] = {
23092321
"set_config",
23102322
(PyCFunction) yara_set_config,
23112323
METH_VARARGS | METH_KEYWORDS,
2312-
"Set a yara configuration variable (stack_size or max_strings_per_rule)"
2324+
"Set a yara configuration variable (stack_size, max_strings_per_rule, or max_match_data)"
23132325
},
23142326
{ NULL, NULL }
23152327
};

0 commit comments

Comments
 (0)