N°2154 - fix server crash in rare cases

Under undetermined circumstances, `exec('php -v')` called the current script triggering an infinite loop crashing the server
problem reported by @molkobain
see: https://stackoverflow.com/questions/43728378/running-php-files-through-shell-exec
This commit is contained in:
bruno DA SILVA
2020-02-19 15:42:59 +01:00
parent d76e54996c
commit 27a0de1da1
3 changed files with 17 additions and 83 deletions

View File

@@ -32,7 +32,7 @@ class iTopConfigAstValidatorTest extends ItopTestCase
public function testValidCode()
{
$oiTopConfigValidator = new iTopConfigSyntaxValidator();
$oiTopConfigValidator->Validate("<?php \n echo 'foo'; ", false);
$oiTopConfigValidator->Validate("<?php \n echo 'foo'; ");
}
public function testThrowOnInvalidCode()
@@ -41,10 +41,10 @@ class iTopConfigAstValidatorTest extends ItopTestCase
$this->expectException(\Exception::class);
try{
$oiTopConfigValidator->Validate("<?php \n zef;zefzef \n zdadz = azdazd \n zerfgzaezerfgzef>", false);
$oiTopConfigValidator->Validate("<?php \n zef;zefzef \n zdadz = azdazd \n zerfgzaezerfgzef>");
}catch (\Exception $e)
{
$this->assertStringStartsWith('PHP Parse error: syntax error, unexpected \'zdadz\' (T_STRING)', $e->getMessage());
$this->assertStringStartsWith('Error in configuration: syntax error, unexpected \'zdadz\' (T_STRING)', $e->getMessage());
throw $e;
}
}