Merge pull request #4601 from taosdata/coverity-fix

[TD-2438]<fix>: Coverity fix
This commit is contained in:
Shengliang Guan 2020-12-18 09:37:41 +08:00 committed by GitHub
commit 604321dff2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 9 deletions

View File

@ -297,16 +297,14 @@ static int32_t walRestoreWalFile(SWal *pWal, void *pVnode, FWalWrite writeFp, ch
}
}
if (pHead->len > size - sizeof(SWalHead)) {
size = sizeof(SWalHead) + pHead->len;
buffer = realloc(buffer, size);
if (buffer == NULL) {
wError("vgId:%d, file:%s, failed to open for restore since %s", pWal->vgId, name, strerror(errno));
code = TAOS_SYSTEM_ERROR(errno);
if (pHead->len < 0 || pHead->len > size - sizeof(SWalHead)) {
wError("vgId:%d, file:%s, wal head len out of range, hver:%" PRIu64 " len:%d offset:%" PRId64, pWal->vgId, name,
pHead->version, pHead->len, offset);
code = walSkipCorruptedRecord(pWal, pHead, tfd, &offset);
if (code != TSDB_CODE_SUCCESS) {
walFtruncate(pWal, tfd, offset);
break;
}
pHead = buffer;
}
ret = tfRead(tfd, pHead->cont, pHead->len);

View File

@ -76,7 +76,7 @@ int main(int argc, char *argv[]) {
taosInitLog("wal.log", 100000, 10);
SWalCfg walCfg;
SWalCfg walCfg = {0};
walCfg.walLevel = level;
walCfg.keep = keep;