Protect includes (in case dol_include is used without harcoded filename)
This commit is contained in:
parent
58852eaa57
commit
4bfe5d2d4a
1 changed files with 11 additions and 0 deletions
|
|
@ -1603,6 +1603,17 @@ function dol_include_once($relpath, $classname = '')
|
|||
{
|
||||
global $conf, $langs, $user, $mysoc; // Do not remove this. They must be defined for files we make "include". Other globals var must be retrieved with $GLOBALS['var']
|
||||
|
||||
if (strpos($relpath, '..') !== false) {
|
||||
// Found a not valid path
|
||||
dol_syslog('functions::dol_include_once Tried to load a file with a path including a forbidden sequence ".." : ' . $relpath, LOG_WARNING);
|
||||
return false;
|
||||
}
|
||||
if (!preg_match('/\.php$/', $relpath)) {
|
||||
// Found a not valid path
|
||||
dol_syslog('functions::dol_include_once Tried to load a file that is not a PHP file : ' . $relpath, LOG_WARNING);
|
||||
return false;
|
||||
}
|
||||
|
||||
$fullpath = dol_buildpath($relpath);
|
||||
|
||||
if (!file_exists($fullpath)) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue