Laurent Destailleur 2008-09-30 00:10:49 +00:00
parent b5d31f9d5d
commit cf3345a2d5

View File

@ -68,19 +68,41 @@ function test_sql_inject($val)
$sql_inj += eregi('update.+set.+=', $val); $sql_inj += eregi('update.+set.+=', $val);
$sql_inj += eregi('insert[[:space:]]+into', $val); $sql_inj += eregi('insert[[:space:]]+into', $val);
$sql_inj += eregi('select.+from', $val); $sql_inj += eregi('select.+from', $val);
return $sql_inj; return $sql_inj;
} }
foreach ($_GET as $key => $val) // Added by Matelli (See http://matelli.fr/showcases/patchs-dolibarr/patch-dolibarr-fix-sql-injection-check-in-array.html)
function analyse_sql_injection(&$var)
{ {
if (test_sql_inject($val) > 0) if (is_array($var))
unset($_GET[$key]);
}
foreach ($_POST as $key => $val)
{ {
if (test_sql_inject($val) > 0) $result = array();
unset($_POST[$key]); foreach ($var as $key => $value)
{
if (test_sql_inject($key) > 0)
{
unset($var[$key]);
} }
else
{
if (analyse_sql_injection($value))
{
$var[$key] = $value;
}
else
{
unset($var[$key]);
}
}
}
return true;
}
else
{
return (test_sql_inject($var) <= 0);
}
}
analyse_sql_injection($_GET);
analyse_sql_injection($_POST);
// Fin filtre des GET et POST // Fin filtre des GET et POST