From f87407aacfd335398cc6897d3d65103f20ead20a Mon Sep 17 00:00:00 2001 From: Mikkel Kamstrup Erlandsen Date: Wed, 19 Mar 2014 13:32:45 +0100 Subject: device: fix potential integer overflow in mstime64() on 32 bit systems --- src/device.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/device.c b/src/device.c index 1297a85..ef97f72 100644 --- a/src/device.c +++ b/src/device.c @@ -124,7 +124,10 @@ static uint64_t mstime64(void) { struct timeval tv; gettimeofday(&tv, NULL); - return tv.tv_sec * 1000 + tv.tv_usec / 1000; + + // Careful, avoid overflow on 32 bit systems + // time_t could be 4 bytes + return ((long long)tv.tv_sec) * 1000LL + ((long long)tv.tv_usec) / 1000LL; } static struct mux_device* get_mux_device_for_id(int device_id) -- cgit v1.1-32-gdbae