Make WordPress Core

Changeset 4226


Ignore:
Timestamp:
09/25/2006 01:48:48 AM (20 years ago)
Author:
ryan
Message:

Validate backup and fragment files. Don't allow traversal.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2.0/wp-content/plugins/wp-db-backup.php

    r4051 r4226  
    7070                       
    7171                        $this->backup_file = $_GET['backup'];
    72                        
     72                        $this->validate_file($this->backup_file);
     73
    7374                        switch($via) {
    7475                        case 'smtp':
     
    9697                if (isset($_GET['fragment'] )) {
    9798                        list($table, $segment, $filename) = explode(':', $_GET['fragment']);
     99                        $this->validate_file($filename);
    98100                        $this->backup_fragment($table, $segment, $filename);
    99101                }
     
    882884                return;
    883885        } // wp_cron_db_backup
     886
     887        function validate_file($file) {
     888                if (false !== strpos($file, '..'))
     889                        die(__("Cheatin' uh ?"));
     890
     891                if (false !== strpos($file, './'))
     892                        die(__("Cheatin' uh ?"));
     893
     894                if (':' == substr($file, 1, 1))
     895                        die(__("Cheatin' uh ?"));
     896        }
     897
    884898}
    885899
Note: See TracChangeset for help on using the changeset viewer.