svn: /phpdoc/en/trunk/ features/file-upload.xml reference/filesystem/functions/move-uploaded-file.xml

From: Date: Mon, 18 Jul 2016 12:36:51 +0000
Subject: svn: /phpdoc/en/trunk/ features/file-upload.xml reference/filesystem/functions/move-uploaded-file.xml
Groups: php.doc.cvs 
Request: Send a blank email to doc-cvs+get-14345@lists.php.net to get a copy of this message
cmb Mon, 18 Jul 2016 12:36:51 +0000 Revision: http://svn.php.net/viewvc?view=revision&revision=339679 Log: Fix #72609: Insecure example in php.net documentation Bug: https://bugs.php.net/72609 (Open) Insecure example in php.net documentation Changed paths: U phpdoc/en/trunk/features/file-upload.xml U phpdoc/en/trunk/reference/filesystem/functions/move-uploaded-file.xml Modified: phpdoc/en/trunk/features/file-upload.xml =================================================================== --- phpdoc/en/trunk/features/file-upload.xml 2016-07-18 04:04:09 UTC (rev 339678) +++ phpdoc/en/trunk/features/file-upload.xml 2016-07-18 12:36:51 UTC (rev 339679) @@ -230,7 +230,9 @@ foreach ($_FILES["pictures"]["error"] as $key => $error) { if ($error == UPLOAD_ERR_OK) { $tmp_name = $_FILES["pictures"]["tmp_name"][$key]; - $name = $_FILES["pictures"]["name"][$key]; + // basename() may prevent filesystem traversal attacks; + // further validation/sanitation of the filename may be appropriate + $name = basename($_FILES["pictures"]["name"][$key]); move_uploaded_file($tmp_name, "data/$name"); } } @@ -547,6 +549,15 @@ </para> </sect1> + <sect1 role="seealso"> + &reftitle.seealso; + <para> + <simplelist> + <member><link linkend="security.filesystem">Filesystem Security</link></member> + </simplelist> + </para> + </sect1> + </chapter> <!-- Keep this comment at the end of the file Modified: phpdoc/en/trunk/reference/filesystem/functions/move-uploaded-file.xml =================================================================== --- phpdoc/en/trunk/reference/filesystem/functions/move-uploaded-file.xml 2016-07-18 04:04:09 UTC (rev 339678) +++ phpdoc/en/trunk/reference/filesystem/functions/move-uploaded-file.xml 2016-07-18 12:36:51 UTC (rev 339679) @@ -83,7 +83,9 @@ foreach ($_FILES["pictures"]["error"] as $key => $error) { if ($error == UPLOAD_ERR_OK) { $tmp_name = $_FILES["pictures"]["tmp_name"][$key]; - $name = $_FILES["pictures"]["name"][$key]; + // basename() may prevent filesystem traversal attacks; + // further validation/sanitation of the filename may be appropriate + $name = basename($_FILES["pictures"]["name"][$key]); move_uploaded_file($tmp_name, "$uploads_dir/$name"); } }

« previous php.doc.cvs (#14345) next »