Make WordPress Core

Ticket #31600: 31600-incr_decr_offset_type_check.diff

File 31600-incr_decr_offset_type_check.diff, 873 bytes (added by jipmoors, 8 years ago)

Type check on offset

  • src/wp-includes/cache.php

     
    435435                if ( ! is_numeric( $this->cache[ $group ][ $key ] ) )
    436436                        $this->cache[ $group ][ $key ] = 0;
    437437
     438                if ( ! is_numeric( $offset ) ) {
     439                        if ( is_string( $offset ) ) {
     440                                $offset = (int) $offset;
     441                        } else {
     442                                $offset = 0;
     443                        }
     444                }
     445
    438446                $offset = (int) $offset;
    439447
    440448                $this->cache[ $group ][ $key ] -= $offset;
     
    546554                if ( ! is_numeric( $this->cache[ $group ][ $key ] ) )
    547555                        $this->cache[ $group ][ $key ] = 0;
    548556
     557                if ( ! is_numeric( $offset ) ) {
     558                        if ( is_string( $offset ) ) {
     559                                $offset = (int) $offset;
     560                        } else {
     561                                $offset = 0;
     562                        }
     563                }
     564
    549565                $offset = (int) $offset;
    550566
    551567                $this->cache[ $group ][ $key ] += $offset;