mirror of
https://github.com/wolfcw/libfaketime.git
synced 2026-05-17 08:36:28 +03:00
time multiplication overflow fix
In 32 bit platforms, timespecmul2() macro function, overflow occurs during multiplication. Size of `long` type in 32 bit platform is 4 bytes, but the size of `long` type in 64 bit platform is 8 bytes.
This commit is contained in:
@@ -60,9 +60,9 @@
|
||||
#define timermul2(tvp, c, result, prefix) \
|
||||
do \
|
||||
{ \
|
||||
long long tmp_time; \
|
||||
tmp_time = (c) * ((tvp)->tv_sec * SEC_TO_##prefix##SEC + \
|
||||
(tvp)->tv_##prefix##sec); \
|
||||
int64_t tmp_time; \
|
||||
tmp_time = (c) * (int64_t) ((tvp)->tv_sec * SEC_TO_##prefix##SEC + \
|
||||
(int64_t) (tvp)->tv_##prefix##sec); \
|
||||
(result)->tv_##prefix##sec = tmp_time % SEC_TO_##prefix##SEC; \
|
||||
(result)->tv_sec = (tmp_time - (result)->tv_##prefix##sec) / \
|
||||
SEC_TO_##prefix##SEC; \
|
||||
|
||||
Reference in New Issue
Block a user