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>
This commit is contained in:
Côme Chilliet 2021-11-18 10:30:35 +01:00
parent 14f00208e2
commit df25a6de31
No known key found for this signature in database
GPG key ID: A3E2F658B28C760A

View file

@ -191,7 +191,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');
}
}
/**