Impose memory usage limit on external filters. Fixes issue #259

This commit is contained in:
Jean-Francois Dockes
2015-07-18 19:30:49 +02:00
parent c8e9795f9e
commit e59bf51445
8 changed files with 90 additions and 13 deletions
+3
View File
@@ -77,6 +77,8 @@ bool MimeHandlerExec::next_document()
int filtermaxseconds = 900;
m_config->getConfParam("filtermaxseconds", &filtermaxseconds);
int filtermaxmbytes = 0;
m_config->getConfParam("filtermaxmbytes", &filtermaxmbytes);
if (params.empty()) {
// Hu ho
@@ -103,6 +105,7 @@ bool MimeHandlerExec::next_document()
mexec.putenv("RECOLL_CONFDIR", m_config->getConfDir());
mexec.putenv(m_forPreview ? "RECOLL_FILTER_FORPREVIEW=yes" :
"RECOLL_FILTER_FORPREVIEW=no");
mexec.setrlimit_as(filtermaxmbytes);
int status;
try {
+5
View File
@@ -47,6 +47,9 @@ bool MimeHandlerExecMultiple::startCmd()
// Command name
string cmd = params.front();
int filtermaxmbytes = 0;
m_config->getConfParam("filtermaxmbytes", &filtermaxmbytes);
m_maxmemberkb = 50000;
m_config->getConfParam("membermaxkbs", &m_maxmemberkb);
ostringstream oss;
@@ -57,6 +60,8 @@ bool MimeHandlerExecMultiple::startCmd()
m_cmd.putenv(m_forPreview ? "RECOLL_FILTER_FORPREVIEW=yes" :
"RECOLL_FILTER_FORPREVIEW=no");
m_cmd.setrlimit_as(filtermaxmbytes);
// Build parameter list: delete cmd name
vector<string>myparams(params.begin() + 1, params.end());