From: Oliver Kurth Date: Mon, 30 Sep 2019 23:24:27 +0000 (-0700) Subject: Fix potential overflow in timeSync reported by Coverity X-Git-Tag: stable-11.1.0~227 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=eb70f9bc44c9764e76ed10766f62b234a80e1a54;p=thirdparty%2Fopen-vm-tools.git Fix potential overflow in timeSync reported by Coverity Issue: Potentially overflowing expression: data->timeSyncPeriod * 1000000U is evaluated using 32-bit arithmetic, and then used in a context that expects an expression of type uint64. Fix: explict type conversion. --- diff --git a/open-vm-tools/services/plugins/timeSync/timeSync.c b/open-vm-tools/services/plugins/timeSync/timeSync.c index 75d3a05c8..514078075 100644 --- a/open-vm-tools/services/plugins/timeSync/timeSync.c +++ b/open-vm-tools/services/plugins/timeSync/timeSync.c @@ -1,5 +1,5 @@ /********************************************************* - * Copyright (C) 2008-2018 VMware, Inc. All rights reserved. + * Copyright (C) 2008-2019 VMware, Inc. All rights reserved. * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published @@ -459,9 +459,9 @@ TimeSyncSlewTime(TimeSyncData *data, int64 adjustment) int64 now; int64 remaining = 0; - int64 timeSyncPeriodUS = data->timeSyncPeriod * US_PER_SEC; + int64 timeSyncPeriodUS = (int64)data->timeSyncPeriod * US_PER_SEC; int64 slewDiff = (adjustment * data->slewPercentCorrection) / 100; - + if (!TimeSync_GetCurrentTime(&now)) { return FALSE; } @@ -537,7 +537,7 @@ static void TimeSyncResetSlew(TimeSyncData *data) { int64 remaining; - int64 timeSyncPeriodUS = data->timeSyncPeriod * US_PER_SEC; + int64 timeSyncPeriodUS = (int64)data->timeSyncPeriod * US_PER_SEC; data->slewState = TimeSyncUncalibrated; TimeSync_Slew(0, timeSyncPeriodUS, &remaining); if (TimeSync_PLLSupported()) {