Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F14407386
D17543.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
D17543.diff
View Options
diff --git a/src/applications/files/builtin/PhabricatorFilesComposeAvatarBuiltinFile.php b/src/applications/files/builtin/PhabricatorFilesComposeAvatarBuiltinFile.php
--- a/src/applications/files/builtin/PhabricatorFilesComposeAvatarBuiltinFile.php
+++ b/src/applications/files/builtin/PhabricatorFilesComposeAvatarBuiltinFile.php
@@ -119,6 +119,7 @@
foreach ($list as $file) {
$map['alphanumeric/'.$file] = $root.$file;
}
+
return $map;
}
@@ -138,11 +139,11 @@
$border_seed = $username.'_border';
$pack_key =
- PhabricatorHash::digestToRange($pack_seed, 1, $pack_count);
+ PhabricatorHash::digestToRange($pack_seed, 0, $pack_count - 1);
$color_key =
- PhabricatorHash::digestToRange($color_seed, 1, $color_count);
+ PhabricatorHash::digestToRange($color_seed, 0, $color_count - 1);
$border_key =
- PhabricatorHash::digestToRange($border_seed, 1, $border_count);
+ PhabricatorHash::digestToRange($border_seed, 0, $border_count - 1);
$pack = $pack_map[$pack_key];
$icon = 'alphanumeric/'.$pack.'/'.$file.'.png';
@@ -188,7 +189,7 @@
->withFollowSymlinks(false)
->find();
- return $map;
+ return array_values($map);
}
public static function getBorderMap() {
diff --git a/src/infrastructure/util/PhabricatorHash.php b/src/infrastructure/util/PhabricatorHash.php
--- a/src/infrastructure/util/PhabricatorHash.php
+++ b/src/infrastructure/util/PhabricatorHash.php
@@ -88,9 +88,10 @@
}
$hash = sha1($string, $raw_output = true);
- $value = head(unpack('L', $hash));
+ // Make sure this ends up positive, even on 32-bit machines.
+ $value = head(unpack('L', $hash)) & 0x7FFFFFFF;
- return $min + ($value % ($max - $min));
+ return $min + ($value % (1 + $max - $min));
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, Dec 25, 2:50 AM (8 h, 23 m)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6924521
Default Alt Text
D17543.diff (1 KB)
Attached To
Mode
D17543: Fix some range issues and 32-bit issues with avatar generation
Attached
Detach File
Event Timeline
Log In to Comment