]> source.dussan.org Git - nextcloud-server.git/commitdiff
Make sure that hash function returns a string
authorCôme Chilliet <come.chilliet@nextcloud.com>
Thu, 18 Nov 2021 09:30:35 +0000 (10:30 +0100)
committerCôme Chilliet <come.chilliet@nextcloud.com>
Tue, 14 Dec 2021 09:58:47 +0000 (10:58 +0100)
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>
apps/user_ldap/lib/Mapping/AbstractMapping.php

index 966d930481c9c6daf2f03880fb686f0b498fda7d..20f22b7529f0212a3dbc761b7654d9bca6f27e61 100644 (file)
@@ -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');
+               }
        }
 
        /**