Skip to content

Commit 47c2443

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 04bd9e6 commit 47c2443

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
@@ -395,16 +395,14 @@ ssize_t strbuf_read_once(struct strbuf *sb, int fd, size_t hint)
395395
return cnt;
396396
}
397397

398-
#define STRBUF_MAXLINK (2*PATH_MAX)
399-
400398
int strbuf_readlink(struct strbuf *sb, const char *path, size_t hint)
401399
{
402400
size_t oldalloc = sb->alloc;
403401

404402
if (hint < 32)
405403
hint = 32;
406404

407-
while (hint < STRBUF_MAXLINK) {
405+
for (;; hint *= 2) {
408406
int len;
409407

410408
strbuf_grow(sb, hint + 1);
@@ -416,9 +414,6 @@ int strbuf_readlink(struct strbuf *sb, const char *path, size_t hint)
416414
strbuf_setlen(sb, len);
417415
return 0;
418416
}
419-
420-
/* .. the buffer was too small - try again */
421-
hint *= 2;
422417
}
423418
if (oldalloc == 0)
424419
strbuf_release(sb);

0 commit comments

Comments
 (0)