提交 6515c9c7 编写于 作者: K kailixu

fix: real path optimization in case of invalid read

上级 a186cc44
......@@ -49,7 +49,7 @@ int tsdbOpen(SVnode *pVnode, STsdb **ppTsdb, const char *dir, STsdbKeepCfg *pKee
pTsdb->path = (char *)&pTsdb[1];
snprintf(pTsdb->path, TD_PATH_MAX, "%s%s%s", pVnode->path, TD_DIRSEP, dir);
taosRealPath(pTsdb->path, NULL, slen);
// taosRealPath(pTsdb->path, NULL, slen);
pTsdb->pVnode = pVnode;
taosThreadRwlockInit(&pTsdb->rwLock, NULL);
if (!pKeepCfg) {
......
......@@ -336,12 +336,14 @@ int32_t taosRealPath(char *dirname, char *realPath, int32_t maxlen) {
#else
if (realpath(dirname, tmp) != NULL) {
#endif
if (realPath == NULL) {
strncpy(dirname, tmp, maxlen);
} else {
strncpy(realPath, tmp, maxlen);
if (strlen(tmp) < maxlen) {
if (realPath == NULL) {
strncpy(dirname, tmp, maxlen);
} else {
strncpy(realPath, tmp, maxlen);
}
return 0;
}
return 0;
}
return -1;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册