From 000809964addc83c8f7adcd9c787183fd8ea1962 Mon Sep 17 00:00:00 2001 From: Gary Pendergast Date: Tue, 7 Nov 2017 01:08:11 +0000 Subject: [PATCH] WPDB: Check that `AUTH_SALT` is not empty. In `wpdb::placeholder_escape()`, the key for `hash_hmac()` defaults to `AUTH_SALT`, but `hash_hmac()` will return an empty string if the key is empty. This had the side effect of the string `{}` being incorrectly replaced with a `%` character in queries just about to be run on the database. Props jsonfry. Fixes #42431. git-svn-id: https://develop.svn.wordpress.org/trunk@42120 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/wp-db.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wp-includes/wp-db.php b/src/wp-includes/wp-db.php index 04792d4db4..19f79c42b0 100644 --- a/src/wp-includes/wp-db.php +++ b/src/wp-includes/wp-db.php @@ -1946,7 +1946,7 @@ class wpdb { // If ext/hash is not present, compat.php's hash_hmac() does not support sha256. $algo = function_exists( 'hash' ) ? 'sha256' : 'sha1'; // Old WP installs may not have AUTH_SALT defined. - $salt = defined( 'AUTH_SALT' ) ? AUTH_SALT : (string) rand(); + $salt = defined( 'AUTH_SALT' ) && AUTH_SALT ? AUTH_SALT : (string) rand(); $placeholder = '{' . hash_hmac( $algo, uniqid( $salt, true ), $salt ) . '}'; }