strbuf_readlink: support link targets that exceed PATH_MAX

strbuf_readlink() refuses to read link targets that exceed PATH_MAX (even
if a sufficient size was specified by the caller).

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

Signed-off-by: Karsten Blees <blees@dcon.de>
This commit is contained in:
Karsten Blees authored and Johannes Schindelin committed 2015-11-07 16:43:08 +01:00
1 parent e9ee6c95e7
commit 9c2b36775e
1 file changed
+1 -6
+1 -6
View File
@@ -384,8 +384,6 @@ ssize_t strbuf_read(struct strbuf *sb, int fd, size_t hint)
return sb->len - oldlen;
}
#define STRBUF_MAXLINK (2*PATH_MAX)
int strbuf_readlink(struct strbuf *sb, const char *path, size_t hint)
{
size_t oldalloc = sb->alloc;
@@ -393,7 +391,7 @@ int strbuf_readlink(struct strbuf *sb, const char *path, size_t hint)
if (hint < 32)
hint = 32;
while (hint < STRBUF_MAXLINK) {
for (;; hint *= 2) {
int len;
strbuf_grow(sb, hint + 1);
@@ -405,9 +403,6 @@ int strbuf_readlink(struct strbuf *sb, const char *path, size_t hint)
strbuf_setlen(sb, len);
return 0;
}
/* .. the buffer was too small - try again */
hint *= 2;
}
if (oldalloc == 0)
strbuf_release(sb);