diff options
| author | Rémy Oudompheng <oudomphe@phare.normalesup.org> | 2013-03-18 20:11:11 +0100 |
|---|---|---|
| committer | Rémy Oudompheng <oudomphe@phare.normalesup.org> | 2013-03-18 20:11:11 +0100 |
| commit | ba50e4f1203ad5cc20b7ada2fce4da62ab195622 (patch) | |
| tree | bc15b58f8552e26bd235ec6b04d3a40a7771c8a5 /src/pkg/runtime/os_linux.c | |
| parent | e7537157a53de8683167a512a67218bd3ea44e39 (diff) | |
| download | go-ba50e4f1203ad5cc20b7ada2fce4da62ab195622.tar.xz | |
runtime: fix tv_sec 32-bit overflows in sleep routines.
Fixes #5063.
R=golang-dev, minux.ma, rsc
CC=golang-dev
https://golang.org/cl/7876043
Diffstat (limited to 'src/pkg/runtime/os_linux.c')
| -rw-r--r-- | src/pkg/runtime/os_linux.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/src/pkg/runtime/os_linux.c b/src/pkg/runtime/os_linux.c index dc1e274378..8aa4c3d35d 100644 --- a/src/pkg/runtime/os_linux.c +++ b/src/pkg/runtime/os_linux.c @@ -36,15 +36,17 @@ void runtime·futexsleep(uint32 *addr, uint32 val, int64 ns) { Timespec ts, *tsp; + int64 secs; if(ns < 0) tsp = nil; else { - ts.tv_sec = ns/1000000000LL; - ts.tv_nsec = ns%1000000000LL; + secs = ns/1000000000LL; // Avoid overflow - if(ts.tv_sec > 1<<30) - ts.tv_sec = 1<<30; + if(secs > 1LL<<30) + secs = 1LL<<30; + ts.tv_sec = secs; + ts.tv_nsec = ns%1000000000LL; tsp = &ts; } |
