From 24a6a0a9fe02d75d7b98ff33fe6afa41c679a475 Mon Sep 17 00:00:00 2001 From: gccgdb1234 Date: Mon, 13 Jun 2022 16:14:37 +0800 Subject: [PATCH] fix: port the fixing of issue 13529 from develop to 2.6 --- src/tsdb/inc/tsdbFile.h | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/tsdb/inc/tsdbFile.h b/src/tsdb/inc/tsdbFile.h index 75e9563151..8436786157 100644 --- a/src/tsdb/inc/tsdbFile.h +++ b/src/tsdb/inc/tsdbFile.h @@ -257,7 +257,13 @@ static FORCE_INLINE int tsdbAppendDFile(SDFile* pDFile, void* buf, int64_t nbyte return -1; } - ASSERT(pDFile->info.size == toffset); + //bug fix. To avoid data corruption, + //the end offset of current file should be checked with file size, + //if not equal, known as file corrupted and return error. + if (pDFile->info.size != toffset) { + terrno = TSDB_CODE_TDB_FILE_CORRUPTED; + return -1; + } if (offset) { *offset = toffset; -- GitLab