]> 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>
Mon, 13 Dec 2021 08:39:55 +0000 (09:39 +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 d3ace159b0c7d0ca5c96e1eb57d4d709da340c08..1d3e1a221f732e797bc54b97e20541fd8a6c4b54 100644 (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');
+               }
        }
 
        /**