Skip to content

Commit

Permalink
fix(tsdb/close): fix uaf with file closing
Browse files Browse the repository at this point in the history
  • Loading branch information
stephenkgu committed Aug 25, 2023
1 parent ebf00c4 commit f0fdbaa
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions source/dnode/vnode/src/tsdb/tsdbReaderWriter.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,31 +35,31 @@ static int32_t tsdbOpenFileImpl(STsdbFD *pFD) {

if (pFD->pFD == NULL) {
code = TAOS_SYSTEM_ERROR(ENOENT);
taosMemoryFree(pFD);
// taosMemoryFree(pFD);
goto _exit;
}
} else {
code = TAOS_SYSTEM_ERROR(errsv);
taosMemoryFree(pFD);
// taosMemoryFree(pFD);
goto _exit;
}
}

pFD->pBuf = taosMemoryCalloc(1, szPage);
if (pFD->pBuf == NULL) {
code = TSDB_CODE_OUT_OF_MEMORY;
taosCloseFile(&pFD->pFD);
taosMemoryFree(pFD);
// taosCloseFile(&pFD->pFD);
// taosMemoryFree(pFD);
goto _exit;
}

// not check file size when reading data files.
if (flag != TD_FILE_READ) {
if (taosStatFile(path, &pFD->szFile, NULL, NULL) < 0) {
code = TAOS_SYSTEM_ERROR(errno);
taosMemoryFree(pFD->pBuf);
taosCloseFile(&pFD->pFD);
taosMemoryFree(pFD);
// taosMemoryFree(pFD->pBuf);
// taosCloseFile(&pFD->pFD);
// taosMemoryFree(pFD);
goto _exit;
}

Expand Down

0 comments on commit f0fdbaa

Please sign in to comment.