未验证 提交 604321df 编写于 作者: S Shengliang Guan 提交者: GitHub

Merge pull request #4601 from taosdata/coverity-fix

[TD-2438]<fix>: Coverity fix
...@@ -297,16 +297,14 @@ static int32_t walRestoreWalFile(SWal *pWal, void *pVnode, FWalWrite writeFp, ch ...@@ -297,16 +297,14 @@ static int32_t walRestoreWalFile(SWal *pWal, void *pVnode, FWalWrite writeFp, ch
} }
} }
if (pHead->len > size - sizeof(SWalHead)) { if (pHead->len < 0 || pHead->len > size - sizeof(SWalHead)) {
size = sizeof(SWalHead) + pHead->len; wError("vgId:%d, file:%s, wal head len out of range, hver:%" PRIu64 " len:%d offset:%" PRId64, pWal->vgId, name,
buffer = realloc(buffer, size); pHead->version, pHead->len, offset);
if (buffer == NULL) { code = walSkipCorruptedRecord(pWal, pHead, tfd, &offset);
wError("vgId:%d, file:%s, failed to open for restore since %s", pWal->vgId, name, strerror(errno)); if (code != TSDB_CODE_SUCCESS) {
code = TAOS_SYSTEM_ERROR(errno); walFtruncate(pWal, tfd, offset);
break; break;
} }
pHead = buffer;
} }
ret = tfRead(tfd, pHead->cont, pHead->len); ret = tfRead(tfd, pHead->cont, pHead->len);
......
...@@ -76,7 +76,7 @@ int main(int argc, char *argv[]) { ...@@ -76,7 +76,7 @@ int main(int argc, char *argv[]) {
taosInitLog("wal.log", 100000, 10); taosInitLog("wal.log", 100000, 10);
SWalCfg walCfg; SWalCfg walCfg = {0};
walCfg.walLevel = level; walCfg.walLevel = level;
walCfg.keep = keep; walCfg.keep = keep;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册