From 631a583fc3f516f92ffd36cb8dd0378b99177bb3 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/branches/ruby_1_8@9505 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 9 +++++++-- file.c | 8 +++++++- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 489b08eac..b00bbac01 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Sun Nov 6 20:13:27 2005 Nobuyoshi Nakada + + * file.c (rb_file_s_readlink): readlink(2) on AIX fails with ERANGE if + buffer size is less than required. fixed: [ruby-dev:27634] + Wed Nov 2 20:25:28 2005 Hidetoshi NAGAI * ext/tk/extconf.rb: ext/tk/extconf.rb: change the check parameter @@ -9,7 +14,7 @@ Wed Nov 2 20:14:53 2005 Hidetoshi NAGAI Wed Nov 2 19:03:06 2005 Hidetoshi NAGAI - * ext/tcltklib/tcltklib.c (ip_rbUpdateObjCmd, + * ext/tcltklib/tcltklib.c (ip_rbUpdateObjCmd, ip_rb_threadUpdateObjCmd): passed improper flags to DoOneEvent(). * ext/tk/tkutil.c: use rb_obj_respond_to() instead of rb_respond_to(). @@ -61,7 +66,7 @@ Mon Oct 31 05:37:20 2005 GOTOU Yuuzou Mon Oct 31 03:19:36 2005 Yukihiro Matsumoto * ext/readline/readline.c (readline_readline): type check. - [ruby-core:6089] + [ruby-core:6089] * numeric.c (fix_rshift): RDoc fix. [ruby-core:6351] diff --git a/file.c b/file.c index 2e465e2d8..898c8009a 100644 --- a/file.c +++ b/file.c @@ -2019,7 +2019,13 @@ rb_file_s_readlink(klass, path) SafeStringValue(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