{"record":{"id":"5aed79859061dc67","repo":"podman-container-tools/podman","slug":"internal-error-path-too-long","errorCode":null,"errorMessage":"internal error: path too long\n","messagePattern":"internal error: path too long\n","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/rootless/rootless_linux.c","lineNumber":464,"sourceCode":"        continue;\n\n      strncpy (buffer + nfiles * (NAME_MAX + 1), de->d_name, NAME_MAX + 1);\n      nfiles++;\n    }\n\n  qsort (buffer, nfiles, NAME_MAX + 1, (int (*)(const void *, const void *)) strcmp);\n\n  for (i = 0; i < nfiles; i++)\n    {\n      const char *fname = buffer + i * (NAME_MAX + 1);\n      char path[PATH_MAX];\n      struct stat st;\n      int ret;\n\n      ret = snprintf (path, PATH_MAX, \"%s/%s\", dir, fname);\n      if (ret == PATH_MAX)\n        {\n          fprintf (stderr, \"internal error: path too long\\n\");\n          exit (EXIT_FAILURE);\n        }\n\n      ret = stat (path, &st);\n      if (ret < 0)\n        {\n          /* Ignore the failure if the file was deleted.  */\n          if (errno == ENOENT)\n            continue;\n\n          fprintf (stderr, \"stat %s: %m\\n\", path);\n          exit (EXIT_FAILURE);\n        }\n\n      /* Not an executable.  */\n      if ((st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH)) == 0)\n        continue;\n","sourceCodeStart":446,"sourceCodeEnd":482,"githubUrl":"https://github.com/podman-container-tools/podman/blob/a2409076ef2fef60ad9ac046375dedc7d9410ef4/pkg/rootless/rootless_linux.c#L446-L482","documentation":"For each entry in a preexec-hooks dir, do_preexec_hooks_dir() composes '<dir>/<filename>' into a char path[PATH_MAX] with snprintf and treats a return of PATH_MAX as overflow (pkg/rootless/rootless_linux.c:461-465). Because filenames are capped at NAME_MAX (255), in practice the hooks directory path itself must be near PATH_MAX (4096) to trigger this. It is an internal sanity assertion, not an expected runtime error.","triggerScenarios":"A hooks directory (e.g. via PODMAN_PREEXEC_HOOKS_DIR) deployed at a path roughly 4090+ characters long, or a symlink-resolved dir path of that length; deliberate path fuzzing of the env var.","commonSituations":"Never seen in normal packaging; only with scripted generation of absurdly deep directory trees or hostile environment fuzzing. Note the upstream check is 'ret == PATH_MAX' where 'ret >= PATH_MAX' would be stricter, so it is marked 'internal error'.","solutions":["Shorten the hooks dir path: keep hooks in the default locations (/etc/containers/pre-exec-hooks, LIBEXECPODMAN/pre-exec-hooks)","Print ${#PODMAN_PREEXEC_HOOKS_DIR} and ensure it is well under 4096 - 256 characters","Unset PODMAN_PREEXEC_HOOKS_DIR or remove /etc/containers/podman_preexec_hooks.txt to bypass hooks entirely","If triggered without an obviously long path, report upstream - it indicates memory corruption or a patched build"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"# Reject absurd hook dir paths before podman scans them\nd=\"${PODMAN_PREEXEC_HOOKS_DIR:-}\"\nif [ -n \"$d\" ] && [ \"${#d}\" -ge 3800 ]; then\n  echo \"preexec hooks dir path too long: ${#d} chars\" >&2\n  exit 1\nfi\n","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep hook directories at the default shallow locations","Validate exported path variables for sane lengths in env bootstrap scripts"],"tags":["preexec-hooks","path","internal-error","path-max"],"backgroundTag":null,"analyzedSha":"a2409076ef2fef60ad9ac046375dedc7d9410ef4","analyzedAt":"2026-08-15T15:57:05.625Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}