Skip to content

Commit

Permalink
Merge pull request #22758 from taosdata/FIX/TD-26161-3.1
Browse files Browse the repository at this point in the history
fix: break potential infinite loop in tfsMkdirRecurAt
  • Loading branch information
gccgdb1234 committed Sep 7, 2023
2 parents e12d22a + 9745313 commit e1aa62e
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion source/libs/tfs/src/tfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ int32_t tfsMkdirRecurAt(STfs *pTfs, const char *rname, SDiskID diskId) {
// https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man3/dirname.3.html
char *dir = taosStrdup(taosDirName(s));

if (tfsMkdirRecurAt(pTfs, dir, diskId) < 0) {
if (strlen(dir) >= strlen(rname) || tfsMkdirRecurAt(pTfs, dir, diskId) < 0) {
taosMemoryFree(s);
taosMemoryFree(dir);
return -1;
Expand Down

0 comments on commit e1aa62e

Please sign in to comment.