The cache directory holds every indexed project's graph database. When a custom * CBM_CACHE_DIR sits inside a repository — which happens in tests and is legal in * production — walking into it would pull other projects' databases into this * project's file list. Prune it by absolute path. * * This is the narrow remedy for a concern that was briefly implemented as * refusing any root containi
| 585 | * refusing any root containing the cache: refusing a whole root was too blunt, |
| 586 | * and not walking the cache is what the concern actually asks for. */ |
| 587 | static bool dir_is_cache_tree(const char *abs_path) { |
| 588 | const char *cache = g_walk_cache_dir; |
| 589 | if (!cache[0] || !abs_path || !abs_path[0]) { |
| 590 | return false; |
| 591 | } |
| 592 | size_t n = strlen(cache); |
| 593 | while (n > 1 && (cache[n - 1] == '/' || cache[n - 1] == '\\')) { |
| 594 | n--; |
| 595 | } |
| 596 | if (strncmp(abs_path, cache, n) != 0) { |
| 597 | return false; |
| 598 | } |
| 599 | /* Boundary-aware so "<cache>x" is not treated as living under "<cache>". */ |
| 600 | return abs_path[n] == '\0' || abs_path[n] == '/' || abs_path[n] == '\\'; |
| 601 | } |
| 602 | |
| 603 | static bool should_skip_directory(const char *entry_name, const char *rel_path, |
| 604 | const cbm_discover_opts_t *opts, const cbm_gitignore_t *gitignore, |
no outgoing calls
no test coverage detected