aboutsummaryrefslogtreecommitdiff
path: root/strbuf.c
diff options
context:
space:
mode:
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;
}