From fb3080079e60697c37e7580ea88b76577bac05dd Mon Sep 17 00:00:00 2001 From: Karsten Blees Date: Mon, 11 May 2015 22:15:40 +0200 Subject: [PATCH] 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 --- strbuf.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/strbuf.c b/strbuf.c index 193ed3362b..74c06fde4b 100644 --- a/strbuf.c +++ b/strbuf.c @@ -459,8 +459,6 @@ 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; @@ -468,7 +466,7 @@ int strbuf_readlink(struct strbuf *sb, const char *path, size_t hint) if (hint < 32) hint = 32; - while (hint < STRBUF_MAXLINK) { + for (;; hint *= 2) { int len; strbuf_grow(sb, hint + 1); @@ -480,9 +478,6 @@ int strbuf_readlink(struct strbuf *sb, const char *path, size_t hint) strbuf_setlen(sb, len); return 0; } - - /* .. the buffer was too small - try again */ - hint *= 2; } if (oldalloc == 0) strbuf_release(sb);