mirror of
https://github.com/fscotto/fsnap.git
synced 2026-11-26 03:09:51 +00:00
_PC_PATH_MAX belongs to pathconf, not sysconf. On glibc _PC_PATH_MAX and _SC_OPEN_MAX are both 4, so sysconf(_PC_PATH_MAX) silently returned the open-file limit (524288 here) and the fallback allocated 512KB per link. Where the two constants do not collide sysconf returns -1, which becomes SIZE_MAX and makes calloc fail, so create would break on every symlink whose st_size is 0. readlink also does not terminate the buffer and truncates silently when the target does not fit, so check the returned length rather than only testing for -1. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018KyCHPAxWzqa3vHKdXJkgx