Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
dolibarr
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container Registry
Model registry
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Software_Artifact_Infrastructure_Repository
dolibarr
Commits
277fa7db
Commit
277fa7db
authored
8 years ago
by
Laurent Destailleur
Browse files
Options
Downloads
Patches
Plain Diff
FIX #6444
parent
fbbcec2b
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
htdocs/core/lib/files.lib.php
+12
-2
12 additions, 2 deletions
htdocs/core/lib/files.lib.php
with
12 additions
and
2 deletions
htdocs/core/lib/files.lib.php
+
12
−
2
View file @
277fa7db
...
...
@@ -1139,6 +1139,7 @@ function dol_move_uploaded_file($src_file, $dest_file, $allowoverwrite, $disable
* @param int $nohook Disable all hooks
* @param object $object Current object in use
* @return boolean True if no error (file is deleted or if glob is used and there's nothing to delete), False if error
* @see dol_delete_dir
*/
function
dol_delete_file
(
$file
,
$disableglob
=
0
,
$nophperrors
=
0
,
$nohook
=
0
,
$object
=
null
)
{
...
...
@@ -1151,8 +1152,8 @@ function dol_delete_file($file,$disableglob=0,$nophperrors=0,$nohook=0,$object=n
dol_syslog
(
"dol_delete_file file="
.
$file
.
" disableglob="
.
$disableglob
.
" nophperrors="
.
$nophperrors
.
" nohook="
.
$nohook
);
// Security:
// We refuse
cache files/dirs, upload
using .. and pipes into filenames.
if
(
preg_match
(
'/^\./'
,
$file
)
||
preg_match
(
'/\.\./'
,
$file
)
||
preg_match
(
'/[<>|]/'
,
$file
))
// We refuse
transversal
using .. and pipes into filenames.
if
(
preg_match
(
'/\.\./'
,
$file
)
||
preg_match
(
'/[<>|]/'
,
$file
))
{
dol_syslog
(
"Refused to delete file "
.
$file
,
LOG_WARNING
);
return
False
;
...
...
@@ -1222,9 +1223,18 @@ function dol_delete_file($file,$disableglob=0,$nophperrors=0,$nohook=0,$object=n
* @param string $dir Directory to delete
* @param int $nophperrors Disable all PHP output errors
* @return boolean True if success, false if error
* @see dol_delete_file
*/
function
dol_delete_dir
(
$dir
,
$nophperrors
=
0
)
{
// Security:
// We refuse transversal using .. and pipes into filenames.
if
(
preg_match
(
'/\.\./'
,
$dir
)
||
preg_match
(
'/[<>|]/'
,
$dir
))
{
dol_syslog
(
"Refused to delete dir "
.
$dir
,
LOG_WARNING
);
return
False
;
}
$dir_osencoded
=
dol_osencode
(
$dir
);
return
(
$nophperrors
?@
rmdir
(
$dir_osencoded
)
:
rmdir
(
$dir_osencoded
));
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment