Skip to content

Commit c29c56e

Browse files
kbleesdscho
authored andcommitted
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 a64c53b commit c29c56e

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
@@ -401,16 +401,14 @@ ssize_t strbuf_write(struct strbuf *sb, FILE *f)
401401
}
402402

403403

404-
#define STRBUF_MAXLINK (2*PATH_MAX)
405-
406404
int strbuf_readlink(struct strbuf *sb, const char *path, size_t hint)
407405
{
408406
size_t oldalloc = sb->alloc;
409407

410408
if (hint < 32)
411409
hint = 32;
412410

413-
while (hint < STRBUF_MAXLINK) {
411+
for (;; hint *= 2) {
414412
int len;
415413

416414
strbuf_grow(sb, hint + 1);
@@ -422,9 +420,6 @@ int strbuf_readlink(struct strbuf *sb, const char *path, size_t hint)
422420
strbuf_setlen(sb, len);
423421
return 0;
424422
}
425-
426-
/* .. the buffer was too small - try again */
427-
hint *= 2;
428423
}
429424
if (oldalloc == 0)
430425
strbuf_release(sb);

0 commit comments

Comments
 (0)