Skip to content

Commit be1432b

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 aeeff0e commit be1432b

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

410410

411-
#define STRBUF_MAXLINK (2*PATH_MAX)
412-
413411
int strbuf_readlink(struct strbuf *sb, const char *path, size_t hint)
414412
{
415413
size_t oldalloc = sb->alloc;
416414

417415
if (hint < 32)
418416
hint = 32;
419417

420-
while (hint < STRBUF_MAXLINK) {
418+
for (;; hint *= 2) {
421419
int len;
422420

423421
strbuf_grow(sb, hint + 1);
@@ -429,9 +427,6 @@ int strbuf_readlink(struct strbuf *sb, const char *path, size_t hint)
429427
strbuf_setlen(sb, len);
430428
return 0;
431429
}
432-
433-
/* .. the buffer was too small - try again */
434-
hint *= 2;
435430
}
436431
if (oldalloc == 0)
437432
strbuf_release(sb);

0 commit comments

Comments
 (0)