Files
fsnap/src
Fabio Scotto di Santolo 695a0f37d7 Read symlink targets with pathconf, and detect truncation
_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
2026-08-26 15:09:33 +02:00
..