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
Unknown Object (File)
Wed, Apr 24, 5:34 PM
Unknown Object (File)
Thu, Apr 11, 9:10 AM
Unknown Object (File)
Tue, Apr 9, 3:09 AM
Unknown Object (File)
Sun, Mar 31, 5:01 AM
Unknown Object (File)
Jan 26 2024, 10:44 AM
Unknown Object (File)
Jan 22 2024, 8:42 AM
Unknown Object (File)
Jan 22 2024, 8:31 AM
Unknown Object (File)
Jan 5 2024, 11:36 PM
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.