[wp-trac] [WordPress Trac] #28102: is_string check in validate_file

WordPress Trac noreply at wordpress.org
Fri May 2 08:28:45 UTC 2014


#28102: is_string check in validate_file
----------------------------------+-----------------------------
 Reporter:  IwanLuijksQuestMedia  |      Owner:
     Type:  defect (bug)          |     Status:  new
 Priority:  normal                |  Milestone:  Awaiting Review
Component:  Plugins               |    Version:  3.9
 Severity:  normal                |   Keywords:
  Focuses:  administration        |
----------------------------------+-----------------------------
 When creating a plugin there is the possibility to get an object in
 validate_file's first parameter, since there is no check on the parameters
 this function accepts, it triggers the following warning. Worse: the
 actual plugin activation process keeps adding the plugin to the
 active_plugins list in the *_options table in result.

     Warning: strpos() expects parameter 1 to be string, object given in
 /<path>/wp-includes/functions.php on line    3345
     Call Stack:
     0.0009     937456   1. {main}() /<path>/wp-admin/plugins.php:0
     0.0013    1053776   2. require_once('/<path>/wp-admin/admin.php')
 /<path>/wp-admin/plugins.php:10
     0.0014    1079792   3. require_once('/<path>/wp-load.php') /<path>/wp-
 admin/admin.php:30
     0.0015    1100288   4. require_once('/<path>/wp-config.php') /<path
 >/wp-load.php:29
     0.0019    1240920   5. require_once('/<path>/wp-settings.php') /<path
 >/wp-config.php:92
     0.0969   26021992   6. wp_get_active_and_valid_plugins() /<path>/wp-
 settings.php:212
     0.0971   26023184   7. validate_file() /<path>/wp-
 includes/load.php:506
     0.0971   26023392   8. strpos() /<path>/wp-includes/functions.php:3345

 {{{
 #!diff
 @@ -3342,6 +3342,9 @@
   * @return int 0 means nothing is wrong, greater than 0 means something
 was wrong.
   */
  function validate_file( $file, $allowed_files = '' ) {
 +       if (!is_string($file) || ($allowed_files !== '' &&
 !is_array($allowed_files)))
 +               return 4;
 +
         if ( false !== strpos( $file, '..' ) )
                 return 1;
 }}}

--
Ticket URL: <https://core.trac.wordpress.org/ticket/28102>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list