mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* ruby.c (load_file_internal): bail out if the script is a directory.
[Feature #2408][ruby-core:26925] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35131 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
8a57e0bf82
commit
764d54788a
3 changed files with 18 additions and 1 deletions
|
@ -1,4 +1,7 @@
|
|||
Mon Mar 26 11:41:01 2012 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
Mon Mar 26 11:46:01 2012 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* ruby.c (load_file_internal): bail out if the script is a directory.
|
||||
[Feature #2408][ruby-core:26925]
|
||||
|
||||
* win32/win32.c (rb_w32_open, rb_w32_wopen): check if the file is a
|
||||
directory when access denied, to set errno to EISDIR.
|
||||
|
|
9
ruby.c
9
ruby.c
|
@ -1524,9 +1524,18 @@ load_file_internal(VALUE arg)
|
|||
}
|
||||
#endif
|
||||
if ((fd = rb_cloexec_open(fname, mode, 0)) < 0) {
|
||||
load_failed:
|
||||
rb_load_fail(fname_v, strerror(errno));
|
||||
}
|
||||
rb_update_max_fd(fd);
|
||||
{
|
||||
struct stat st;
|
||||
if (fstat(fd, &st) != 0) goto load_failed;
|
||||
if (S_ISDIR(st.st_mode)) {
|
||||
errno = EISDIR;
|
||||
goto load_failed;
|
||||
}
|
||||
}
|
||||
|
||||
f = rb_io_fdopen(fd, mode, fname);
|
||||
}
|
||||
|
|
|
@ -553,4 +553,9 @@ class TestRubyOptions < Test::Unit::TestCase
|
|||
assert_in_out_err(["-C", dir, a], "", [], /LoadError/, bug3851)
|
||||
end
|
||||
end
|
||||
|
||||
def test_script_is_directory
|
||||
feature2408 = '[ruby-core:26925]'
|
||||
assert_in_out_err(%w[.], "", [], /Is a directory -- \./, feature2408)
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Reference in a new issue