diff options
| author | 2014-03-19 13:32:45 +0100 | |
|---|---|---|
| committer | 2014-03-24 17:01:30 +0100 | |
| commit | f87407aacfd335398cc6897d3d65103f20ead20a (patch) | |
| tree | c14ea6379dc09b8b310c85147d4183cd2b249e94 /src/device.c | |
| parent | f545cc75f7caa5afa9a8f5a937344010d4d58e7d (diff) | |
| download | usbmuxd-f87407aacfd335398cc6897d3d65103f20ead20a.tar.gz usbmuxd-f87407aacfd335398cc6897d3d65103f20ead20a.tar.bz2 | |
device: fix potential integer overflow in mstime64() on 32 bit systems
Diffstat (limited to 'src/device.c')
| -rw-r--r-- | src/device.c | 5 |
1 files changed, 4 insertions, 1 deletions
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) | |||
| 124 | { | 124 | { |
| 125 | struct timeval tv; | 125 | struct timeval tv; |
| 126 | gettimeofday(&tv, NULL); | 126 | gettimeofday(&tv, NULL); |
| 127 | return tv.tv_sec * 1000 + tv.tv_usec / 1000; | 127 | |
| 128 | // Careful, avoid overflow on 32 bit systems | ||
| 129 | // time_t could be 4 bytes | ||
| 130 | return ((long long)tv.tv_sec) * 1000LL + ((long long)tv.tv_usec) / 1000LL; | ||
| 128 | } | 131 | } |
| 129 | 132 | ||
| 130 | static struct mux_device* get_mux_device_for_id(int device_id) | 133 | static struct mux_device* get_mux_device_for_id(int device_id) |
