Make sure that hash function returns a string

The documentation says it can return false, and even if that is highly
 unlikely for sha256, better safe than sorry.

Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
pull/30261/head
Côme Chilliet 2021-11-18 10:30:35 +07:00
parent d8263692d0
commit 41e365aa3b
No known key found for this signature in database
GPG Key ID: A3E2F658B28C760A
1 changed files with 6 additions and 1 deletions

@ -192,7 +192,12 @@ abstract class AbstractMapping {
* Get the hash to store in database column ldap_dn_hash for a given dn
*/
protected function getDNHash(string $fdn): string {
return (string)hash('sha256', $fdn, false);
$hash = hash('sha256', $fdn, false);
if (is_string($hash)) {
return $hash;
} else {
throw new \RuntimeException('hash function did not return a string');
}
}
/**