From 44044678a17b6063323039738ab76d86bc499c12 Mon Sep 17 00:00:00 2001 From: huyx Date: Fri, 16 Aug 2024 18:21:15 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E5=91=8A=E8=AD=A6=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: huyx --- framework/support/posix/src/osal_time.c | 6 +++--- interfaces/inner_api/hdi/base/hdi_smq.h | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/framework/support/posix/src/osal_time.c b/framework/support/posix/src/osal_time.c index 0b3d2a56b..9f076f226 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 0c488453c..e10e62e6c 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; } -- Gitee From d18f27cfad84351933eb9171dfb9565d6dc4897f Mon Sep 17 00:00:00 2001 From: huyx Date: Wed, 21 Aug 2024 10:24:14 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: huyx --- framework/support/posix/src/osal_time.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/framework/support/posix/src/osal_time.c b/framework/support/posix/src/osal_time.c index 9f076f226..8c3fafb5d 100644 --- a/framework/support/posix/src/osal_time.c +++ b/framework/support/posix/src/osal_time.c @@ -52,8 +52,8 @@ int32_t OsalDiffTime(const OsalTimespec *start, const OsalTimespec *end, OsalTim sec = 1; } - if (start->sec + sec > UINT64_MAX || usec + end->usec > UINT64_MAX || - end->sec < start->sec + sec || end->usec + usec> start->usec) { + 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; } -- Gitee From 17a5688ff18b2d41d21e45fe89c3bda82c3d53ac Mon Sep 17 00:00:00 2001 From: huyx Date: Wed, 21 Aug 2024 10:27:11 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: huyx --- framework/support/posix/src/osal_time.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/framework/support/posix/src/osal_time.c b/framework/support/posix/src/osal_time.c index 8c3fafb5d..34a1b4781 100644 --- a/framework/support/posix/src/osal_time.c +++ b/framework/support/posix/src/osal_time.c @@ -52,8 +52,8 @@ int32_t OsalDiffTime(const OsalTimespec *start, const OsalTimespec *end, OsalTim sec = 1; } - if ((start->sec + sec) > UINT64_MAX || (usec + end->usec) > UINT64_MAX || - end->sec < (start->sec + sec) || (end->usec + usec) < start->usec) { + 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; } -- Gitee