Page MenuHomePhabricator

Fix some range issues and 32-bit issues with avatar generation
ClosedPublic

Authored by epriestley on Mar 23 2017, 5:48 PM.
Tags
None
Referenced Files
F19725944: D17543.diff
Fri, Feb 13, 5:08 PM
F19722479: D17543.id.diff
Fri, Feb 13, 3:35 AM
F19722477: D17543.id.diff
Fri, Feb 13, 3:31 AM
F19699976: D17543.id42195.diff
Tue, Feb 10, 8:21 PM
F19304078: D17543.diff
Dec 24 2025, 7:07 AM
F19094498: D17543.id42195.diff
Dec 4 2025, 1:01 AM
F19040152: D17543.id42195.diff
Nov 26 2025, 11:15 AM
F18826225: D17543.id.diff
Oct 24 2025, 2:59 AM
Subscribers
None

Details

Summary

Ref T12444. A few issues:

  • x % (y - z) doesn't generate values in the full range: the largest value is never generated. Instead, use x % (1 + y - z).
  • digestToRange(1, count) never generates 0. After fixing the first bug, it could generate count. The range of the arrays is 0..(count-1), inclusive. Generate the correct range instead.
  • unpack('L', ...) can unpack a negative number on a 32-bit system. Use & 0x7FFFFFFF to mask off the sign bit so the result is always a positive integer.
  • FileFinder might return arbitrary keys, but we rely on sequential keys (0, 1, 2, ...)
Test Plan
  • Used bin/people profileimage ... --force to regenerate images.
  • Added some debugging to verify that the math seemed to be working.

Diff Detail

Repository
rP Phabricator
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

This revision is now accepted and ready to land.Mar 23 2017, 5:50 PM

Like 3/4ths of these were my fault, sorry I am so bad at math.

This revision was automatically updated to reflect the committed changes.