diff --git a/src/gausskernel/storage/file/fd.cpp b/src/gausskernel/storage/file/fd.cpp index f99bae1bc..381ecf5f3 100644 --- a/src/gausskernel/storage/file/fd.cpp +++ b/src/gausskernel/storage/file/fd.cpp @@ -3512,13 +3512,16 @@ void RemovePgTempFiles(void) * subDir returned by ReadDir will be overwritten by the next invoking. * therefore, the result needs to be saved. */ + char curSubDir[MAXPGPATH] = {0}; + rc = strncpy_s(curSubDir, MAXPGPATH, spc_de->d_name, strlen(spc_de->d_name)); + securec_check(rc, "", ""); #ifdef PGXC /* Postgres-XC tablespaces include node name in path */ rc = snprintf_s(temp_path, sizeof(temp_path), sizeof(temp_path) - 1, "pg_tblspc/%s/%s_%s/%s", - spc_de->d_name, + curSubDir, TABLESPACE_VERSION_DIRECTORY, g_instance.attr.attr_common.PGXCNodeName, PG_TEMP_FILES_DIR); @@ -3528,7 +3531,7 @@ void RemovePgTempFiles(void) sizeof(temp_path), sizeof(temp_path) - 1, "pg_tblspc/%s/%s/%s", - spc_de->d_name, + curSubDir, TABLESPACE_VERSION_DIRECTORY, PG_TEMP_FILES_DIR); securec_check_ss(rc, "", ""); @@ -3541,7 +3544,7 @@ void RemovePgTempFiles(void) sizeof(temp_path), sizeof(temp_path) - 1, "pg_tblspc/%s/%s_%s", - spc_de->d_name, + curSubDir, TABLESPACE_VERSION_DIRECTORY, g_instance.attr.attr_common.PGXCNodeName); securec_check_ss(rc, "", ""); @@ -3550,7 +3553,7 @@ void RemovePgTempFiles(void) sizeof(temp_path), sizeof(temp_path) - 1, "pg_tblspc/%s/%s", - spc_de->d_name, + curSubDir, TABLESPACE_VERSION_DIRECTORY); securec_check_ss(rc, "\0", "\0"); #endif @@ -4055,4 +4058,4 @@ PageCompressHeader *GetPageCompressMemoryMap(File file, uint32 chunk_size) } return vfdP->pcmap; -} \ No newline at end of file +}