summaryrefslogtreecommitdiffstats
path: root/server
diff options
context:
space:
mode:
authorFrediano Ziglio <fziglio@redhat.com>2015-08-21 10:21:46 +0100
committerFrediano Ziglio <fziglio@redhat.com>2015-08-26 15:24:09 +0100
commit068bf4e83d2a615c26cdfc6ba7120590eacfed51 (patch)
tree22b6c871d36a6f5c1f498155cc0215c2c7f80483 /server
parent6001d8905e1f7af36b06c5ee10e187a832fb3c90 (diff)
downloadspice-068bf4e83d2a615c26cdfc6ba7120590eacfed51.tar.gz
spice-068bf4e83d2a615c26cdfc6ba7120590eacfed51.tar.xz
spice-068bf4e83d2a615c26cdfc6ba7120590eacfed51.zip
prevent integer overflow on 32 bit
On 32 bit machine timespec->tv_sec (time_t) is 32 bit. Also 1000 * 1000 * 1000 is 32 bit. The multiplication of 2 32 bit integers gives a 32 bit integer, however this can overflow. Converting the first factor to 64 bit before the multiplication solves the issue. Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Diffstat (limited to 'server')
-rw-r--r--server/red_worker.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/server/red_worker.c b/server/red_worker.c
index 9c6921b6..eeffdd0a 100644
--- a/server/red_worker.c
+++ b/server/red_worker.c
@@ -164,7 +164,7 @@ static void rendering_incorrect(const char *msg)
static inline red_time_t timespec_to_red_time(struct timespec *time)
{
- return time->tv_sec * (1000 * 1000 * 1000) + time->tv_nsec;
+ return (red_time_t) time->tv_sec * (1000 * 1000 * 1000) + time->tv_nsec;
}
static clockid_t clock_id;