Changes from trunk/src/wp-includes/pluggable.php at r28053 to branches/3.9/src/wp-includes/pluggable.php at r29408
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/3.9/src/wp-includes/pluggable.php
r28053 r29408 648 648 $hash = hash_hmac('md5', $username . '|' . $expiration, $key); 649 649 650 if ( hash_hmac( 'md5', $hmac, $key ) !== hash_hmac( 'md5', $hash, $key) ) {650 if ( ! hash_equals( $hash, $hmac ) ) { 651 651 /** 652 652 * Fires if a bad authentication cookie hash is encountered. … … 1659 1659 1660 1660 // Nonce generated 0-12 hours ago 1661 if ( substr(wp_hash($i . $action . $uid, 'nonce'), -12, 10) === $nonce ) 1661 $expected = substr( wp_hash( $i . '|' . $action . '|' . $uid, 'nonce'), -12, 10 ); 1662 if ( hash_equals( $expected, $nonce ) ) { 1662 1663 return 1; 1664 } 1665 1663 1666 // Nonce generated 12-24 hours ago 1664 if ( substr(wp_hash(($i - 1) . $action . $uid, 'nonce'), -12, 10) === $nonce ) 1667 $expected = substr( wp_hash( ( $i - 1 ) . '|' . $action . '|' . $uid, 'nonce' ), -12, 10 ); 1668 if ( hash_equals( $expected, $nonce ) ) { 1665 1669 return 2; 1670 } 1671 1666 1672 // Invalid nonce 1667 1673 return false; … … 1688 1694 $i = wp_nonce_tick(); 1689 1695 1690 return substr(wp_hash($i . $action. $uid, 'nonce'), -12, 10);1696 return substr(wp_hash($i . '|' . $action . '|' . $uid, 'nonce'), -12, 10); 1691 1697 } 1692 1698 endif; … … 2108 2114 $avatar = "<img alt='{$safe_alt}' src='{$out}' class='avatar avatar-{$size} photo' height='{$size}' width='{$size}' />"; 2109 2115 } else { 2110 $avatar = "<img alt='{$safe_alt}' src='{$default}' class='avatar avatar-{$size} photo avatar-default' height='{$size}' width='{$size}' />"; 2116 $out = esc_url( $default ); 2117 $avatar = "<img alt='{$safe_alt}' src='{$out}' class='avatar avatar-{$size} photo avatar-default' height='{$size}' width='{$size}' />"; 2111 2118 } 2112 2119 … … 2201 2208 endif; 2202 2209 2210 if ( ! function_exists( 'hash_equals' ) ) : 2211 /** 2212 * Compare two strings in constant time. 2213 * 2214 * This function is NOT pluggable. It is in this file (in addition to 2215 * compat.php) to prevent errors if, during an update, pluggable.php 2216 * copies over but compat.php does not. 2217 * 2218 * This function was added in PHP 5.6. 2219 * It can leak the length of a string. 2220 * 2221 * @since 3.9.2 2222 * 2223 * @param string $a Expected string. 2224 * @param string $b Actual string. 2225 * @return bool Whether strings are equal. 2226 */ 2227 function hash_equals( $a, $b ) { 2228 $a_length = strlen( $a ); 2229 if ( $a_length !== strlen( $b ) ) { 2230 return false; 2231 } 2232 $result = 0; 2233 2234 // Do not attempt to "optimize" this. 2235 for ( $i = 0; $i < $a_length; $i++ ) { 2236 $result |= ord( $a[ $i ] ) ^ ord( $b[ $i ] ); 2237 } 2238 2239 return $result === 0; 2240 } 2241 endif;
Note: See TracChangeset
for help on using the changeset viewer.