Limit the result of regexroute function $(variables,list) so it doesn't crash when there is a very large number of variables.

git-svn-id: http://yate.null.ro/svn/yate/trunk@5931 acf43c95-373e-0410-b603-e72c3f656dc1
This commit is contained in:
paulc 2015-01-07 17:14:32 +00:00
parent 7f38064c6d
commit aeaca4e94b
1 changed files with 8 additions and 1 deletions

View File

@ -29,6 +29,7 @@ namespace { // anonymous
#define DEFAULT_RULE "^\\(false\\|no\\|off\\|disable\\|f\\|0*\\)$^"
#define BLOCK_STACK 10
#define MAX_VAR_LEN 8100
static Configuration s_cfg;
static const char* s_trackName = 0;
@ -407,8 +408,14 @@ static void evalFunc(String& str, Message& msg)
if (par.null())
par = ",";
str.clear();
for (const ObjList* l = s_vars.paramList()->skipNull(); l; l = l->skipNext())
for (const ObjList* l = s_vars.paramList()->skipNull(); l; l = l->skipNext()) {
if (str.length() > MAX_VAR_LEN) {
Debug("RegexRoute",DebugWarn,"Truncating output of $(variables,list)");
str.append("...",par);
break;
}
str.append(static_cast<const NamedString*>(l->get())->name(),par);
}
}
else
str = !!s_vars.getParam(par);