From df25a6de310608925bc96ca5fd91bcc851f49969 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=B4me=20Chilliet?= Date: Thu, 18 Nov 2021 10:30:35 +0100 Subject: [PATCH] Make sure that hash function returns a string MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- apps/user_ldap/lib/Mapping/AbstractMapping.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/apps/user_ldap/lib/Mapping/AbstractMapping.php b/apps/user_ldap/lib/Mapping/AbstractMapping.php index 18b76a0bf15..aea40c577b6 100644 --- a/apps/user_ldap/lib/Mapping/AbstractMapping.php +++ b/apps/user_ldap/lib/Mapping/AbstractMapping.php @@ -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'); + } } /**