Ensure that hash directory computation is the same on both 32 and 64 bit architecture...
authorpdontthink <pdontthink@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Sat, 14 Feb 2009 07:32:38 +0000 (07:32 +0000)
committerpdontthink <pdontthink@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Sat, 14 Feb 2009 07:32:38 +0000 (07:32 +0000)
git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@13403 7612ce4b-ef26-0410-bec9-ea0150e637f0

ChangeLog
functions/prefs.php

index c861340e1df88f504f97e4b56c186bc8e2ad83df..45724f53f2d483c33e2d9c2283b49a015710bb23 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -270,6 +270,8 @@ Version 1.5.2 - SVN
   - Make all submit button names unique on compose screen
   - Make address book file permissions 0600 - same as preference files
   - Added compatibility with Dovecot's bigint UIDs
   - Make all submit button names unique on compose screen
   - Make address book file permissions 0600 - same as preference files
   - Added compatibility with Dovecot's bigint UIDs
+  - Ensure that hash directory computation is the same on both 32 and
+    64 bit architectures (#2596879).
 
 Version 1.5.1 (branched on 2006-02-12)
 --------------------------------------
 
 Version 1.5.1 (branched on 2006-02-12)
 --------------------------------------
index 5b618d5623d6d57fb933e4b3376b7a03756ddeda..8d02042d62914fde1edabc2b8545d12ab3dbb196 100644 (file)
@@ -117,8 +117,15 @@ function getHashedDir($username, $dir, $hash_dirs = '') {
  * @since 1.2.0
  */
 function computeHashDirs($username) {
  * @since 1.2.0
  */
 function computeHashDirs($username) {
-    /* Compute the hash for this user and extract the hash directories. */
-    $hash = base_convert(crc32($username), 10, 16);
+    /* Compute the hash for this user and extract the hash directories.  */ 
+    /* Note that the crc32() function result will be different on 32 and */ 
+    /* 64 bit systems, thus the hack below.                              */
+    $crc = crc32($username);
+    if ($crc & 0x80000000) {
+        $crc ^= 0xffffffff;
+        $crc += 1;
+    }
+    $hash = base_convert($crc, 10, 16);
     $hash_dirs = array();
     for ($h = 0; $h < 4; ++ $h) {
         $hash_dirs[] = substr($hash, $h, 1);
     $hash_dirs = array();
     for ($h = 0; $h < 4; ++ $h) {
         $hash_dirs[] = substr($hash, $h, 1);