From 2c7d1fe39f76d46c6d980b287453063ec10097d6 Mon Sep 17 00:00:00 2001 From: Jef Driesen Date: Sat, 24 Mar 2018 13:13:09 +0100 Subject: [PATCH] Use 64bit arithmetic to avoid overflow The multiplication is evaluated using 32bit arithmetic, and then stored in a 64bit integer. The 32bit integer overflow can be avoided by casting to a 64bit type first. --- src/serial_posix.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/serial_posix.c b/src/serial_posix.c index 352655b..6f2ae71 100644 --- a/src/serial_posix.c +++ b/src/serial_posix.c @@ -691,7 +691,7 @@ dc_serial_read (dc_iostream_t *abstract, void *data, size_t size, size_t *actual if (init) { // Calculate the initial timeout. - timeout = device->timeout * 1000; + timeout = (dc_usecs_t) device->timeout * 1000; // Calculate the target time. target = now + timeout; init = 0;