1
0
mirror of https://github.com/fwbuilder/fwbuilder synced 2026-03-24 12:17:26 +01:00

* ../src/compiler_lib/Configlet.cpp (Configlet::expand): added

basic protection against infinite loops in configlet expansion.
This commit is contained in:
Vadim Kurland 2010-02-16 15:40:13 +00:00
parent 8207738eff
commit af51aea7a1
3 changed files with 21 additions and 3 deletions

View File

@ -1 +1 @@
#define BUILD_NUM 2544
#define BUILD_NUM 2546

View File

@ -1,3 +1,8 @@
2010-02-16 vadim <vadim@vk.crocodile.org>
* ../src/compiler_lib/Configlet.cpp (Configlet::expand): added
basic protection against infinite loops in configlet expansion.
2010-02-15 vadim <vadim@vk.crocodile.org>
* Added template for the OpenWRT firewall. Fixes #1237

View File

@ -177,7 +177,8 @@ QString Configlet::expand()
} else
all_code = code.join("\n");
while (all_code.contains(var_re))
int counter = 0;
while (all_code.contains(var_re) && counter < 1000)
{
QString var = var_re.cap(1);
if (vars.count(var) > 0)
@ -190,9 +191,21 @@ QString Configlet::expand()
all_code.replace(QString("{{$%1}}").arg(var), QString("{{%1}}").arg(var));
}
counter++;
}
while (processIf(all_code, 0));
if (counter >= 1000)
qDebug() << QObject::tr("Configlet expansion stopped by "
"infinite loop protector. "
"Check configlet syntax. %1").arg(file_path);
counter = 0;
while (processIf(all_code, 0) && counter < 1000) counter++;
if (counter >= 1000)
qDebug() << QObject::tr("Configlet expansion stopped by "
"infinite loop protector. "
"Check configlet syntax. %1").arg(file_path);
if (collapse_empty_strings)
{