{"record":{"id":"58e549add883deca","repo":"NationalSecurityAgency/ghidra","slug":"s-error-too-many-files-encountered-n","errorCode":null,"errorMessage":"%s: error: too many @-files encountered\\n","messagePattern":"(.+?): error: too many @-files encountered\\\\n","errorType":"console","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"GPL/DemanglerGnu/src/demangler_gnu_v2_41/c/argv.c","lineNumber":406,"sourceCode":"      /* A dynamically allocated buffer used to hold options read from a\n\t response file.  */\n      char *buffer;\n      /* Dynamically allocated storage for the options read from the\n\t response file.  */\n      char **file_argv;\n      /* The number of options read from the response file, if any.  */\n      size_t file_argc;\n#ifdef S_ISDIR\n      struct stat sb;\n#endif\n      /* We are only interested in options of the form \"@file\".  */\n      filename = (*argvp)[i];\n      if (filename[0] != '@')\n\tcontinue;\n      /* If we have iterated too many times then stop.  */\n      if (-- iteration_limit == 0)\n\t{\n\t  fprintf (stderr, \"%s: error: too many @-files encountered\\n\", (*argvp)[0]);\n\t  xexit (1);\n\t}\n#ifdef S_ISDIR\n      if (stat (filename+1, &sb) < 0)\n\tcontinue;\n      if (S_ISDIR(sb.st_mode))\n\t{\n\t  fprintf (stderr, \"%s: error: @-file refers to a directory\\n\", (*argvp)[0]);\n\t  xexit (1);\n\t}\n#endif\n      /* Read the contents of the file.  */\n      f = fopen (++filename, \"r\");\n      if (!f)\n\tcontinue;\n      if (fseek (f, 0L, SEEK_END) == -1)\n\tgoto error;\n      pos = ftell (f);","sourceCodeStart":388,"sourceCodeEnd":424,"githubUrl":"https://github.com/NationalSecurityAgency/ghidra/blob/d5f144c24d6bc53c9cbf4448c6d11143e7696206/GPL/DemanglerGnu/src/demangler_gnu_v2_41/c/argv.c#L388-L424","documentation":"The expandargv function processes @file response-file arguments iteratively. A decrementing iteration_limit guards against infinite loops from circular references (e.g. @a includes @b which includes @a). When the limit reaches zero, the tool prints this error and calls xexit(1), terminating immediately.","triggerScenarios":"Response files (@file) are deeply nested or circular; the cumulative count of @-file expansions exceeds iteration_limit. Each @-file encountered decrements the counter; hitting zero triggers the fatal exit.","commonSituations":"Circular response file references (@a contains @b, @b contains @a); build systems that auto-generate deeply nested response files; accidentally pointing an @file at itself.","solutions":["Flatten nested response files into a single file","Break circular @-file references","Audit the response file chain to identify the loop","Reduce the total number of @-file indirections"],"exampleFix":"# before: @outer.txt contains @inner.txt which contains @outer.txt\n# after: merge all options into a single flat @all-options.txt","handlingStrategy":"validation","validationCode":"// Before calling expandargv, check for circular or excessively nested @-files\n#include <sys/stat.h>\nstatic int count_response_file_depth(const char *path, int depth) {\n    if (depth > 16) return -1; // arbitrary safety limit\n    FILE *f = fopen(path, \"r\");\n    if (!f) return depth;\n    char line[4096];\n    int max_child = depth;\n    while (fgets(line, sizeof(line), f)) {\n        char *at = strchr(line, '@');\n        if (at && at[1] != '\\0' && at[1] != '\\n') {\n            int d = count_response_file_depth(at + 1, depth + 1);\n            if (d < 0) { fclose(f); return -1; }\n            if (d > max_child) max_child = d;\n        }\n    }\n    fclose(f);\n    return max_child;\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Flatten response files — avoid nesting @-files within @-files","Detect circular references with a visited-set before expanding","Keep response file chains shallow (ideally one level)","Generate response files from a single flat source"],"tags":["cli","arguments","response-file","c"],"backgroundTag":null,"analyzedSha":"d5f144c24d6bc53c9cbf4448c6d11143e7696206","analyzedAt":"2026-08-14T01:00:57.564Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}