diff --git a/frameworks/config_policy/src/config_policy_utils.c b/frameworks/config_policy/src/config_policy_utils.c index 06c4187eb12b4a57633e209af0f1823df7f42864..54d8ca3a64525c81ec5441da70a99cacda6233fc 100644 --- a/frameworks/config_policy/src/config_policy_utils.c +++ b/frameworks/config_policy/src/config_policy_utils.c @@ -490,7 +490,7 @@ CfgFiles *GetCfgFilesEx(const char *pathSuffix, int followMode, const char *extr access(buf, F_OK) == 0) { files->paths[index++] = strdup(buf); } - for (int j = 0; result && j < result->segCount; j++) { + for (int j = 0; result && j < result->segCount && index < MAX_CFG_POLICY_DIRS_CNT; j++) { if (result->segs[j] && snprintf_s(buf, MAX_PATH_LEN, MAX_PATH_LEN - 1, "%s/%s/%s", dirs->paths[i], result->segs[j], pathSuffix) > 0 &&