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 <blees@dcon.de>
This commit is contained in:
Karsten Blees 2015-05-11 22:15:40 +02:00 коммит произвёл Matthew John Cheetham
Родитель f8a0dd488c
Коммит a0a8305190
1 изменённых файлов: 1 добавлений и 3 удалений

Просмотреть файл

@ -567,8 +567,6 @@ ssize_t strbuf_write(struct strbuf *sb, FILE *f)
return sb->len ? fwrite(sb->buf, 1, sb->len, f) : 0;
}
#define STRBUF_MAXLINK (2*PATH_MAX)
int strbuf_readlink(struct strbuf *sb, const char *path, size_t hint)
{
size_t oldalloc = sb->alloc;
@ -576,7 +574,7 @@ int strbuf_readlink(struct strbuf *sb, const char *path, size_t hint)
if (hint < 32)
hint = 32;
while (hint < STRBUF_MAXLINK) {
for (;;) {
ssize_t len;
strbuf_grow(sb, hint + 1);