]> git.ipfire.org Git - thirdparty/open-vm-tools.git/commitdiff
Fix potential overflow in timeSync reported by Coverity
authorOliver Kurth <okurth@vmware.com>
Mon, 30 Sep 2019 23:24:27 +0000 (16:24 -0700)
committerOliver Kurth <okurth@vmware.com>
Mon, 30 Sep 2019 23:24:27 +0000 (16:24 -0700)
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.

open-vm-tools/services/plugins/timeSync/timeSync.c

index 75d3a05c825c0ff6ec57c07b1ed3d06dc3cc9f21..514078075c62be4c254577df47ca63d7613f8cbe 100644 (file)
@@ -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()) {