Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/bareos/bareos.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Rogge <andreas.rogge@bareos.com>2022-03-15 16:54:33 +0300
committerAndreas Rogge <andreas.rogge@bareos.com>2022-03-15 17:06:55 +0300
commitf6910bbdf018eb73ee7dceb833d9c1c881051514 (patch)
tree536a0f8aea2ffbee3d93f615c19cf94911128dbc
parent5efbb95ae73896bb10a887f53041b311b8e577d2 (diff)
lib: avoid integer overflows in Bmicrosleep()dev/pstorz/master/testing-full-run-check-git
-rw-r--r--core/src/lib/bsys.cc4
1 files changed, 2 insertions, 2 deletions
diff --git a/core/src/lib/bsys.cc b/core/src/lib/bsys.cc
index ae8eec1fd..79ba740d8 100644
--- a/core/src/lib/bsys.cc
+++ b/core/src/lib/bsys.cc
@@ -161,7 +161,7 @@ int Bmicrosleep(int32_t sec, int32_t usec)
int status;
timeout.tv_sec = sec;
- timeout.tv_nsec = usec * 1000;
+ timeout.tv_nsec = static_cast<decltype(timeout.tv_nsec)>(usec) * 1000l;
#ifdef HAVE_NANOSLEEP
status = nanosleep(&timeout, NULL);
@@ -171,7 +171,7 @@ int Bmicrosleep(int32_t sec, int32_t usec)
// Do it the old way
gettimeofday(&tv, &tz);
- timeout.tv_nsec += tv.tv_usec * 1000;
+ timeout.tv_nsec += static_cast<decltype(timeout.tv_nsec)>(tv.tv_usec) * 1000l;
timeout.tv_sec += tv.tv_sec;
while (timeout.tv_nsec >= 1000000000) {
timeout.tv_nsec -= 1000000000;