Merge pull request #18230 from taosdata/fix/TD-19618-D
fix: real path optimization in case of invalid read
This commit is contained in:
commit
1167c86b34
|
@ -49,7 +49,7 @@ int tsdbOpen(SVnode *pVnode, STsdb **ppTsdb, const char *dir, STsdbKeepCfg *pKee
|
||||||
|
|
||||||
pTsdb->path = (char *)&pTsdb[1];
|
pTsdb->path = (char *)&pTsdb[1];
|
||||||
snprintf(pTsdb->path, TD_PATH_MAX, "%s%s%s", pVnode->path, TD_DIRSEP, dir);
|
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;
|
pTsdb->pVnode = pVnode;
|
||||||
taosThreadRwlockInit(&pTsdb->rwLock, NULL);
|
taosThreadRwlockInit(&pTsdb->rwLock, NULL);
|
||||||
if (!pKeepCfg) {
|
if (!pKeepCfg) {
|
||||||
|
|
|
@ -336,12 +336,14 @@ int32_t taosRealPath(char *dirname, char *realPath, int32_t maxlen) {
|
||||||
#else
|
#else
|
||||||
if (realpath(dirname, tmp) != NULL) {
|
if (realpath(dirname, tmp) != NULL) {
|
||||||
#endif
|
#endif
|
||||||
if (realPath == NULL) {
|
if (strlen(tmp) < maxlen) {
|
||||||
strncpy(dirname, tmp, maxlen);
|
if (realPath == NULL) {
|
||||||
} else {
|
strncpy(dirname, tmp, maxlen);
|
||||||
strncpy(realPath, tmp, maxlen);
|
} else {
|
||||||
|
strncpy(realPath, tmp, maxlen);
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
|
|
Loading…
Reference in New Issue