]> git.ipfire.org Git - thirdparty/git.git/commitdiff
strbuf_readlink(): support link targets that exceed PATH_MAX
authorKarsten Blees <blees@dcon.de>
Tue, 16 Dec 2025 15:33:48 +0000 (15:33 +0000)
committerJunio C Hamano <gitster@pobox.com>
Wed, 17 Dec 2025 23:21:07 +0000 (08:21 +0900)
The `strbuf_readlink()` function refuses to read link targets that
exceed PATH_MAX (even if a sufficient size was specified by the caller).

As some platforms (*cough* Windows *cough*) support longer paths, remove
this restriction (similar to `strbuf_getcwd()`).

Signed-off-by: Karsten Blees <blees@dcon.de>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
strbuf.c

index 44a8f6a554ee43933d79d3106bbf3b6168116fe8..fa4e30f112bb09d07076d874f46e60355eaf7c1d 100644 (file)
--- a/strbuf.c
+++ b/strbuf.c
@@ -566,8 +566,6 @@ ssize_t strbuf_write(struct strbuf *sb, FILE *f)
        return sb->len ? fwrite(sb->buf, 1, sb->len, f) : 0;
 }
 
-#define STRBUF_MAXLINK (2*PATH_MAX)
-
 int strbuf_readlink(struct strbuf *sb, const char *path, size_t hint)
 {
        size_t oldalloc = sb->alloc;
@@ -575,7 +573,7 @@ int strbuf_readlink(struct strbuf *sb, const char *path, size_t hint)
        if (hint < 32)
                hint = 32;
 
-       while (hint < STRBUF_MAXLINK) {
+       for (;;) {
                ssize_t len;
 
                strbuf_grow(sb, hint + 1);