summaryrefslogtreecommitdiff
path: root/dir.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2001-11-08 06:43:14 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2001-11-08 06:43:14 +0000
commitdc98adf839d0d68c4c18647a1db2fb3dc9be8cc4 (patch)
tree7f6e3c4b45359409bf57526308837f5dbbc45905 /dir.c
parentab827130d3f563535abb7404230f5b5e63bf0946 (diff)
* 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
Diffstat (limited to 'dir.c')
-rw-r--r--dir.c22
1 files changed, 9 insertions, 13 deletions
diff --git a/dir.c b/dir.c
index 428f4aaaa6..a7673175e5 100644
--- a/dir.c
+++ b/dir.c
@@ -61,6 +61,8 @@ char *strchr _((char*,char));
#include <ctype.h>
+#include "util.h"
+
#ifndef HAVE_LSTAT
#define lstat(path,st) stat(path,st)
#endif
@@ -430,21 +432,16 @@ static VALUE chdir_thread = Qnil;
static VALUE
chdir_restore(path)
- const char *path;
+ char *path;
{
chdir_blocking--;
if (chdir_blocking == 0)
chdir_thread = Qnil;
dir_chdir(path);
+ free(path);
return Qnil;
}
-#ifdef HAVE_GETCWD
-#define GETCWD(path) if (getcwd(path, sizeof(path)) == 0) rb_sys_fail(path)
-#else
-#define GETCWD(path) if (getwd(path) == 0) rb_sys_fail(path)
-#endif
-
static VALUE
dir_s_chdir(argc, argv, obj)
int argc;
@@ -473,9 +470,7 @@ dir_s_chdir(argc, argv, obj)
}
if (rb_block_given_p()) {
- char cwd[MAXPATHLEN];
-
- GETCWD(cwd);
+ char *cwd = my_getcwd();
chdir_blocking++;
if (chdir_thread == Qnil)
chdir_thread = rb_thread_current();
@@ -491,10 +486,11 @@ static VALUE
dir_s_getwd(dir)
VALUE dir;
{
- char path[MAXPATHLEN];
+ char *path = my_getcwd();
+ VALUE cwd = rb_tainted_str_new2(path);
- GETCWD(path);
- return rb_tainted_str_new2(path);
+ free(path);
+ return cwd;
}
static VALUE