bug: to_disk uses dirname() which may modify its argument (POSIX undefined) #42
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
In src/shared/file.c:412-418, the to_disk function uses dirname() which has platform-dependent behavior:
According to POSIX, dirname() may modify its argument. While the code does pass a duplicate (via str_dup), the behavior of dirname() varies between platforms:
Additionally, after calling dirname(), the original
directorypointer should NOT be freed since it may point to a static buffer (on Linux) rather than the original duplicated allocation.Fix: Either use a portable implementation or avoid dirname() entirely by implementing directory extraction in-path.
Severity: low