diff options
author | Roman Kiryanov <rkir@google.com> | 2019-08-21 11:01:39 -0700 |
---|---|---|
committer | Roman Kiryanov <rkir@google.com> | 2019-08-22 22:46:54 +0000 |
commit | 9872a4d42b2e3309133f2616e099a07284aa3ed3 (patch) | |
tree | cc8d1de54035025387c09772c23988356b9725fb /cmds/incidentd | |
parent | f4fc3e2693a38ca576e7522df2175016f6e9f152 (diff) |
Fix integer overflow in make_timestamp_ns_locked
timespec::tv_sec is time_t which is 32bit wide on
32bit platforms. Multipliyng 32bit integers (tv_sec and
1000) produces another 32bit integer which overflows
in this case and turns into a negative value which
confuses the logic downstream. This change makes the
multiplication to be 64bit which prevent the overflow.
Bug: 139320584
Bug: 139538727
Test: GtsIncidentManagerTestCases
Change-Id: Ie956074961c7c1f08e2519920f7ce69d5c9e12d3
Signed-off-by: Roman Kiryanov <rkir@google.com>
(cherry picked from commit e9db937f4008f097f4ee9dc341a3afc219a96fd9)
Diffstat (limited to 'cmds/incidentd')
-rw-r--r-- | cmds/incidentd/src/WorkDirectory.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/cmds/incidentd/src/WorkDirectory.cpp b/cmds/incidentd/src/WorkDirectory.cpp index 0570c3a039ae..8dcb86537487 100644 --- a/cmds/incidentd/src/WorkDirectory.cpp +++ b/cmds/incidentd/src/WorkDirectory.cpp @@ -664,7 +664,7 @@ int64_t WorkDirectory::make_timestamp_ns_locked() { nanosleep(&spec, nullptr); } clock_gettime(CLOCK_REALTIME, &spec); - timestampNs = (spec.tv_sec) * 1000 + spec.tv_nsec; + timestampNs = int64_t(spec.tv_sec) * 1000 + spec.tv_nsec; } while (file_exists_locked(timestampNs)); return timestampNs; } |