Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Timestamp: Prevent integer overflow on Darwin PPC 32-bit #511

Closed
wants to merge 1 commit into from

Commits on Apr 18, 2014

  1. Timestamp: Prevent integer overflow on Darwin PPC 32-bit

    A Darwin PPC 32-bit user observes huge values numer == 1000000000 and
    denom == 18431683 returned from mach_timebase_info().  For these
    values, mach_absolute_time() * numer overflows uint64_t every 1000.82
    seconds, and 1000000 * denom always overflows uint32_t, with the
    effect of making time run backwards at -11190660 times its usual
    speed.
    
    This bug was masked on Darwin x86 64-bit, where numer == denom == 1.
    
    Fix it by doing the conversion with double arithmetic instead.
    
    Closes mobile-shell#479.
    
    Signed-off-by: Anders Kaseorg <andersk@mit.edu>
    andersk committed Apr 18, 2014
    Configuration menu
    Copy the full SHA
    ba47f9f View commit details
    Browse the repository at this point in the history