From dc98adf839d0d68c4c18647a1db2fb3dc9be8cc4 Mon Sep 17 00:00:00 2001 From: matz Date: Thu, 8 Nov 2001 06:43:14 +0000 Subject: * process.c (security): always give warning for insecure PATH. * dir.c (my_getcwd): do not rely on MAXPATHLEN. * file.c (rb_file_s_readlink): ditto. * file.c (path_check_1): ditto. * eval.c (rb_yield_0): should not call rb_f_block_given_p(). * string.c (rb_str_chomp_bang): should terminate string by NUL. * eval.c (rb_yield_0): better error message. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@1816 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- util.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'util.c') diff --git a/util.c b/util.c index ddc919584c..9c22285a18 100644 --- a/util.c +++ b/util.c @@ -11,6 +11,7 @@ **********************************************************************/ #include +#include #ifdef NT #include "missing/file.h" @@ -628,3 +629,17 @@ ruby_strdup(str) return tmp; } + +char * +ruby_getcwd() +{ + int size = 200; + char *buf = xmalloc(size); + + while (!getcwd(buf, size)) { + if (errno != ERANGE) rb_sys_fail(buf); + size *= 2; + buf = xrealloc(buf, size); + } + return buf; +} -- cgit v1.2.3