Skip to content

Commit 27c549f

Browse files
committed
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 <[email protected]>
1 parent 81b096f commit 27c549f

File tree

1 file changed

+1
-6
lines changed

1 file changed

+1
-6
lines changed

strbuf.c

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -384,16 +384,14 @@ ssize_t strbuf_read(struct strbuf *sb, int fd, size_t hint)
384384
return sb->len - oldlen;
385385
}
386386

387-
#define STRBUF_MAXLINK (2*PATH_MAX)
388-
389387
int strbuf_readlink(struct strbuf *sb, const char *path, size_t hint)
390388
{
391389
size_t oldalloc = sb->alloc;
392390

393391
if (hint < 32)
394392
hint = 32;
395393

396-
while (hint < STRBUF_MAXLINK) {
394+
for (;; hint *= 2) {
397395
int len;
398396

399397
strbuf_grow(sb, hint + 1);
@@ -405,9 +403,6 @@ int strbuf_readlink(struct strbuf *sb, const char *path, size_t hint)
405403
strbuf_setlen(sb, len);
406404
return 0;
407405
}
408-
409-
/* .. the buffer was too small - try again */
410-
hint *= 2;
411406
}
412407
if (oldalloc == 0)
413408
strbuf_release(sb);

0 commit comments

Comments
 (0)