From 948fa60ef0532fa94d8ff5de54e78a33ddcf2bcb Mon Sep 17 00:00:00 2001 From: Benguang Zhao Date: Sun, 9 Oct 2022 11:52:06 +0800 Subject: [PATCH] fix: check the length of remaining content for computing CRC32 chksum of WAL record body --- source/libs/wal/src/walMeta.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/source/libs/wal/src/walMeta.c b/source/libs/wal/src/walMeta.c index 7cc92c46e9..7bf707a8ef 100644 --- a/source/libs/wal/src/walMeta.c +++ b/source/libs/wal/src/walMeta.c @@ -94,8 +94,10 @@ static FORCE_INLINE int64_t walScanLogGetLastVer(SWal* pWal) { break; } SWalCkHead* logContent = (SWalCkHead*)candidate; - if (walValidHeadCksum(logContent) == 0 && walValidBodyCksum(logContent) == 0) { - found = candidate; + if (walValidHeadCksum(logContent) == 0 && + walCkHeadSz + logContent->head.bodyLen <= len && + walValidBodyCksum(logContent) == 0) { + found = candidate; } haystack = candidate + 1; }