aboutsummaryrefslogtreecommitdiff
path: root/strbuf.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2026-01-09 18:32:29 -0800
committerJunio C Hamano <gitster@pobox.com>2026-01-09 18:32:29 -0800
commitec13dca8d0619dc1cfe4cee5801b32bc58792ae2 (patch)
tree4c84be76afefce235e96f2cf18b40262f46a65e8 /strbuf.c
parentc4a0c8845e2426375ad257b6c221a3a7d92ecfda (diff)
parentaa7b8864d841f16044b0d79fce5baaec1830b3e3 (diff)
downloadgit-ec13dca8d0619dc1cfe4cee5801b32bc58792ae2.tar.xz
Merge branch 'js/prep-symlink-windows' into js/symlink-windows
* js/prep-symlink-windows: trim_last_path_component(): avoid hard-coding the directory separator strbuf_readlink(): support link targets that exceed 2*PATH_MAX strbuf_readlink(): avoid calling `readlink()` twice in corner-cases init: do parse _all_ core.* settings early mingw: do resolve symlinks in `getcwd()` t7800: work around the MSYS path conversion on Windows t6423: introduce Windows-specific handling for symlinking to /dev/null t1305: skip symlink tests that do not apply to Windows t1006: accommodate for symlink support in MSYS2 t0600: fix incomplete prerequisite for a test case t0301: another fix for Windows compatibility t0001: handle `diff --no-index` gracefully mingw: special-case `open(symlink, O_CREAT | O_EXCL)` apply: symbolic links lack a "trustable executable bit" t9700: accommodate for Windows paths
Diffstat (limited to 'strbuf.c')
-rw-r--r--strbuf.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/strbuf.c b/strbuf.c
index 6c3851a7f8..ec2b7afbe6 100644
--- a/strbuf.c
+++ b/strbuf.c
@@ -566,7 +566,7 @@ 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)
+#define STRBUF_MAXLINK (32767)
int strbuf_readlink(struct strbuf *sb, const char *path, size_t hint)
{
@@ -578,12 +578,12 @@ int strbuf_readlink(struct strbuf *sb, const char *path, size_t hint)
while (hint < STRBUF_MAXLINK) {
ssize_t len;
- strbuf_grow(sb, hint);
- len = readlink(path, sb->buf, hint);
+ strbuf_grow(sb, hint + 1);
+ len = readlink(path, sb->buf, hint + 1);
if (len < 0) {
if (errno != ERANGE)
break;
- } else if (len < hint) {
+ } else if (len <= hint) {
strbuf_setlen(sb, len);
return 0;
}