Permalink
Browse files

unix: fix integer overflow in uv_hrtime

Conversion to nanoseconds was overflowing with 32-bit builds.
  • Loading branch information...
piscisaureus committed Aug 18, 2012
1 parent d6a96de commit 0233b92eacc0bb442ff54ca338ae07aae28b8418
Showing with 5 additions and 5 deletions.
  1. +1 −1 src/unix/cygwin.c
  2. +1 −1 src/unix/freebsd.c
  3. +1 −1 src/unix/linux.c
  4. +1 −1 src/unix/netbsd.c
  5. +1 −1 src/unix/openbsd.c
View
@@ -34,7 +34,7 @@
uint64_t uv_hrtime() {
struct timespec ts;
clock_gettime(CLOCK_MONOTONIC, &ts);
- return (ts.tv_sec * NANOSEC + ts.tv_nsec);
+ return (((uint64_t) ts.tv_sec) * NANOSEC + ts.tv_nsec);
}
void uv_loadavg(double avg[3]) {
View
@@ -38,7 +38,7 @@
uint64_t uv_hrtime(void) {
struct timespec ts;
clock_gettime(CLOCK_MONOTONIC, &ts);
- return (ts.tv_sec * NANOSEC + ts.tv_nsec);
+ return (((uint64_t) ts.tv_sec) * NANOSEC + ts.tv_nsec);
}
View
@@ -134,7 +134,7 @@ static char* basename_r(const char* path) {
uint64_t uv_hrtime() {
struct timespec ts;
clock_gettime(CLOCK_MONOTONIC, &ts);
- return (ts.tv_sec * NANOSEC + ts.tv_nsec);
+ return (((uint64_t) ts.tv_sec) * NANOSEC + ts.tv_nsec);
}
void uv_loadavg(double avg[3]) {
View
@@ -38,7 +38,7 @@
uint64_t uv_hrtime(void) {
struct timespec ts;
clock_gettime(CLOCK_MONOTONIC, &ts);
- return (ts.tv_sec * NANOSEC + ts.tv_nsec);
+ return (((uint64_t) ts.tv_sec) * NANOSEC + ts.tv_nsec);
}
void uv_loadavg(double avg[3]) {
View
@@ -36,7 +36,7 @@
uint64_t uv_hrtime(void) {
struct timespec ts;
clock_gettime(CLOCK_MONOTONIC, &ts);
- return (ts.tv_sec * NANOSEC + ts.tv_nsec);
+ return (((uint64_t) ts.tv_sec) * NANOSEC + ts.tv_nsec);
}
void uv_loadavg(double avg[3]) {

0 comments on commit 0233b92

Please sign in to comment.