From dedb199313d9cd1e53d1f629cf58145e3335152a Mon Sep 17 00:00:00 2001 From: nobu Date: Sun, 6 Nov 2005 11:18:57 +0000 Subject: * file.c (rb_file_s_readlink): readlink(2) on AIX fails with ERANGE if buffer size is less than required. fixed: [ruby-dev:27634] git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@9505 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- file.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'file.c') diff --git a/file.c b/file.c index c1a69575f..38db9d84b 100644 --- a/file.c +++ b/file.c @@ -1982,7 +1982,13 @@ rb_file_s_readlink(VALUE klass, VALUE path) rb_secure(2); FilePathValue(path); buf = xmalloc(size); - while ((rv = readlink(StringValueCStr(path), buf, size)) == size) { + for (;;) { + rv = readlink(RSTRING(path)->ptr, buf, size); +#ifndef _AIX + if (rv != size) break; +#else + if (rv > 0 || errno != ERANGE) break; +#endif size *= 2; buf = xrealloc(buf, size); } -- cgit