Skip to content

Commit

Permalink
strbuf_readlink: support link targets that exceed PATH_MAX
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
kblees authored and dscho committed Nov 15, 2018
1 parent 740b127 commit 37dbe34
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions strbuf.c
Original file line number Diff line number Diff line change
Expand Up @@ -459,16 +459,14 @@ ssize_t strbuf_write(struct strbuf *sb, FILE *f)
}


#define STRBUF_MAXLINK (2*PATH_MAX)

int strbuf_readlink(struct strbuf *sb, const char *path, size_t hint)
{
size_t oldalloc = sb->alloc;

if (hint < 32)
hint = 32;

while (hint < STRBUF_MAXLINK) {
for (;;) {
ssize_t len;

strbuf_grow(sb, hint + 1);
Expand Down

0 comments on commit 37dbe34

Please sign in to comment.