diff --git a/framework/support/posix/src/osal_time.c b/framework/support/posix/src/osal_time.c index 0b3d2a56b9eb0f9c50ac2d6b60945aff590c6635..34a1b478158290e4ebe8bf2a3ac899533970ca14 100644 --- a/framework/support/posix/src/osal_time.c +++ b/framework/support/posix/src/osal_time.c @@ -42,7 +42,7 @@ int32_t OsalDiffTime(const OsalTimespec *start, const OsalTimespec *end, OsalTim return HDF_ERR_INVALID_PARAM; } - if (start->sec > end->sec) { + if ((start->sec > end->sec) || ((end->sec == start->sec) && (end->usec < start->usec))) { HDF_LOGE("%s start time later then end time", __func__); return HDF_ERR_INVALID_PARAM; } @@ -52,8 +52,8 @@ int32_t OsalDiffTime(const OsalTimespec *start, const OsalTimespec *end, OsalTim sec = 1; } - uint32_t secTime = start->sec + sec; - if (end->sec - secTime < 0 || end->sec > UINT32_MAX - secTime) { + if ((start->sec + sec > UINT64_MAX) || (usec + end->usec > UINT64_MAX) || + (end->sec < start->sec + sec) || (end->usec + usec < start->usec)) { HDF_LOGE("%s end time invalid", __func__); return HDF_ERR_INVALID_PARAM; } diff --git a/interfaces/inner_api/hdi/base/hdi_smq.h b/interfaces/inner_api/hdi/base/hdi_smq.h index 0c488453c16d5a52e108987e365f6aa4ac01a1f3..e10e62e6c8574bfa14cd72c3088d258a7ed9291c 100644 --- a/interfaces/inner_api/hdi/base/hdi_smq.h +++ b/interfaces/inner_api/hdi/base/hdi_smq.h @@ -401,7 +401,7 @@ bool SharedMemQueue::IsGood() template size_t SharedMemQueue::Align(size_t num, size_t alignSize) { - if ((num + alignSize) < 1 || num > (SIZE_MAX - alignSize)) { + if (alignSize < 1 || num > (SIZE_MAX - alignSize)) { HDF_LOGE("Invalid parameter num or alignSize"); return 0; }