N°2154: Fix security breach (scratch install usecase)

This commit is contained in:
odain
2020-01-07 17:44:34 +01:00
parent 94a09493b0
commit fdd79e91f0

View File

@@ -1893,19 +1893,26 @@ class Config
{ {
$sFileName = $this->m_sFile; $sFileName = $this->m_sFile;
} }
$oHandle = fopen($this->m_sFile, 'r'); $oHandle = null;
$index = 0; if (is_file($this->m_sFile))
while (!flock($oHandle, LOCK_SH))
{ {
if ($index > 50){ $oHandle = fopen($this->m_sFile, 'r');
throw new ConfigException("Could not read to configuration file", array('file' => $this->m_sFile)); $index = 0;
while (!flock($oHandle, LOCK_SH))
{
if ($index > 50)
{
throw new ConfigException("Could not read to configuration file", array('file' => $this->m_sFile));
}
usleep(100000);
$index++;
} }
usleep(100000);
$index++;
} }
$this->oItopConfigParser = new iTopConfigParser(file_get_contents($this->m_sFile)); $this->oItopConfigParser = new iTopConfigParser(file_get_contents($this->m_sFile));
flock($oHandle, LOCK_UN); if ($oHandle !==null)
{
flock($oHandle, LOCK_UN);
}
$hFile = @fopen($sFileName, 'w'); $hFile = @fopen($sFileName, 'w');
if ($hFile !== false) if ($hFile !== false)