From ec3c8be6eef54708d20d55f540ee0c7b41c503bd Mon Sep 17 00:00:00 2001 From: chenliming Date: Tue, 22 Mar 2022 18:36:24 +0800 Subject: [PATCH] =?UTF-8?q?chenliming@kaihongdigi.com:=20=E9=98=9F?= =?UTF-8?q?=E5=88=97=E6=94=AF=E6=8C=81=E5=8F=98=E9=95=BF=E8=AF=BB=E6=93=8D?= =?UTF-8?q?=E4=BD=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: chenliming --- kernel/base/ipc/los_queue.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/kernel/base/ipc/los_queue.c b/kernel/base/ipc/los_queue.c index 871a1004..5e01690e 100644 --- a/kernel/base/ipc/los_queue.c +++ b/kernel/base/ipc/los_queue.c @@ -223,6 +223,7 @@ STATIC VOID OsQueueBufferOperate(LosQueueCB *queueCB, UINT32 operateType, VOID * PRINT_ERR("get msgdatasize failed\n"); return; } + msgDataSize = (*bufferSize < msgDataSize) ? *bufferSize : msgDataSize; if (memcpy_s(bufferAddr, *bufferSize, queueNode, msgDataSize) != EOK) { PRINT_ERR("copy message to buffer failed\n"); return; @@ -249,9 +250,7 @@ STATIC UINT32 OsQueueOperateParamCheck(const LosQueueCB *queueCB, UINT32 queueID return LOS_ERRNO_QUEUE_NOT_CREATE; } - if (OS_QUEUE_IS_READ(operateType) && (*bufferSize < (queueCB->queueSize - sizeof(UINT32)))) { - return LOS_ERRNO_QUEUE_READ_SIZE_TOO_SMALL; - } else if (OS_QUEUE_IS_WRITE(operateType) && (*bufferSize > (queueCB->queueSize - sizeof(UINT32)))) { + if (OS_QUEUE_IS_WRITE(operateType) && (*bufferSize > (queueCB->queueSize - sizeof(UINT32)))) { return LOS_ERRNO_QUEUE_WRITE_SIZE_TOO_BIG; } return LOS_OK; -- GitLab