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

Conversation

andersk
Copy link
Member

@andersk andersk commented Apr 18, 2014

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 #479.

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>
@mistydemeo
Copy link

👍

@deutrino
Copy link

Can this be merged or is there still any blocking issue?

@cgull
Copy link
Member

cgull commented May 21, 2015

Have any of you tried this on Darwin/PPC? Once it's tested there I'll pull it.

@mistydemeo
Copy link

Yep, both @gordon-morehouse and I have tested this and it works well.

@cgull
Copy link
Member

cgull commented May 26, 2015

Pulled.

@cgull cgull closed this May 26, 2015
@deutrino
Copy link

Hand-me-down users the world over thank you! ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

mosh doesn't work on PowerPC OS X 10.5 (Leopard)
4 participants