Skip to content

Commit

Permalink
fix: break potential infinite loop in tfsMkdirRecurAt
Browse files Browse the repository at this point in the history
  • Loading branch information
bgzhao66 committed Sep 5, 2023
1 parent 4a287aa commit 0b077a8
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 0b077a8

Please sign in to comment.