]> git.99rst.org Git - git.git/commit
strbuf_readlink(): avoid calling `readlink()` twice in corner-cases
authorKarsten Blees <redacted>
Fri, 9 Jan 2026 20:05:07 +0000 (20:05 +0000)
committerJunio C Hamano <redacted>
Sat, 10 Jan 2026 02:28:36 +0000 (18:28 -0800)
commit0fcbb57f970f318df422ca756a269651885576b9
tree2f51b009cb71b86d0601214c270011ea9a5c92cb
parent7997e36561b9f7c084ea37ec280708736ab3dcb4
strbuf_readlink(): avoid calling `readlink()` twice in corner-cases

The `strbuf_readlink()` function calls `readlink()`` twice if the hint
argument specifies the exact size of the link target (e.g. by passing
stat.st_size as returned by `lstat()`). This is necessary because
`readlink(..., hint) == hint` could mean that the buffer was too small.

Use `hint + 1` as buffer size to prevent this.

Signed-off-by: Karsten Blees <redacted>
Signed-off-by: Johannes Schindelin <redacted>
Signed-off-by: Junio C Hamano <redacted>
strbuf.c
git clone https://git.99rst.org/PROJECT