Skip to content

Commit

Permalink
Merge pull request taosdata#8794 from haoyifan/dfile_name_parse_fix
Browse files Browse the repository at this point in the history
Fix DFile name parsing bug
  • Loading branch information
guanshengliang authored Oct 24, 2022
2 parents 2a660b0 + 1de4db9 commit fb6a8b1
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/tsdb/src/tsdbFile.c
Original file line number Diff line number Diff line change
Expand Up @@ -683,19 +683,20 @@ int tsdbScanAndTryFixDFileSet(STsdbRepo *pRepo, SDFileSet *pSet) {
}

int tsdbParseDFilename(const char *fname, int *vid, int *fid, TSDB_FILE_T *ftype, uint32_t *_version) {
char *p = NULL;
#define MAX_SUFFIX_LEN 10
char suffix[MAX_SUFFIX_LEN] = {0};
*_version = 0;
*ftype = TSDB_FILE_MAX;

sscanf(fname, "v%df%d.%m[a-z]-ver%" PRIu32, vid, fid, &p, _version);
// "suffix" needs to be constrained by 1 less MAX_SUFFIX_LEN
sscanf(fname, "v%df%d.%9[a-z]-ver%" PRIu32, vid, fid, suffix, _version);
for (TSDB_FILE_T i = 0; i < TSDB_FILE_MAX; i++) {
if (strcmp(p, TSDB_FNAME_SUFFIX[i]) == 0) {
if (strcmp(suffix, TSDB_FNAME_SUFFIX[i]) == 0) {
*ftype = i;
break;
}
}

tfree(p);
return 0;
}

Expand Down

0 comments on commit fb6a8b1

Please sign in to comment.