* win32/win32.c (check_if_dir, check_if_wdir): fix for Visual C++
not to use S_ISDIR(). [Feature #2408][ruby-core:26925] * ruby.c (load_file_internal): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35134 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
06fba52338
commit
7a0d81eaa2
@ -1,3 +1,10 @@
|
|||||||
|
Mon Mar 26 13:51:23 2012 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
|
* win32/win32.c (check_if_dir, check_if_wdir): fix for Visual C++
|
||||||
|
not to use S_ISDIR(). [Feature #2408][ruby-core:26925]
|
||||||
|
|
||||||
|
* ruby.c (load_file_internal): ditto.
|
||||||
|
|
||||||
Mon Mar 26 11:46: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.
|
* ruby.c (load_file_internal): bail out if the script is a directory.
|
||||||
|
9
ruby.c
9
ruby.c
@ -1524,19 +1524,20 @@ load_file_internal(VALUE arg)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
if ((fd = rb_cloexec_open(fname, mode, 0)) < 0) {
|
if ((fd = rb_cloexec_open(fname, mode, 0)) < 0) {
|
||||||
load_failed:
|
|
||||||
rb_load_fail(fname_v, strerror(errno));
|
rb_load_fail(fname_v, strerror(errno));
|
||||||
}
|
}
|
||||||
rb_update_max_fd(fd);
|
rb_update_max_fd(fd);
|
||||||
|
#if !defined DOSISH && !defined __CYGWIN__
|
||||||
{
|
{
|
||||||
struct stat st;
|
struct stat st;
|
||||||
if (fstat(fd, &st) != 0) goto load_failed;
|
if (fstat(fd, &st) != 0)
|
||||||
|
rb_load_fail(fname_v, strerror(errno));
|
||||||
if (S_ISDIR(st.st_mode)) {
|
if (S_ISDIR(st.st_mode)) {
|
||||||
errno = EISDIR;
|
errno = EISDIR;
|
||||||
goto load_failed;
|
rb_load_fail(fname_v, strerror(EISDIR));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
f = rb_io_fdopen(fd, mode, fname);
|
f = rb_io_fdopen(fd, mode, fname);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5188,9 +5188,18 @@ rb_w32_uopen(const char *file, int oflag, ...)
|
|||||||
static int
|
static int
|
||||||
check_if_dir(const char *file)
|
check_if_dir(const char *file)
|
||||||
{
|
{
|
||||||
struct stati64 st;
|
DWORD attr;
|
||||||
if (rb_w32_stati64(file, &st) != 0 || !S_ISDIR(st.st_mode))
|
WCHAR *wfile;
|
||||||
|
|
||||||
|
if (!(wfile = filecp_to_wstr(file, NULL)))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
attr = GetFileAttributesW(wfile);
|
||||||
|
if (attr == (DWORD)-1L ||
|
||||||
|
!(attr & FILE_ATTRIBUTE_DIRECTORY) ||
|
||||||
|
check_valid_dir(wfile)) {
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
free(wfile);
|
||||||
errno = EISDIR;
|
errno = EISDIR;
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
@ -5199,9 +5208,12 @@ check_if_dir(const char *file)
|
|||||||
static int
|
static int
|
||||||
check_if_wdir(const WCHAR *wfile)
|
check_if_wdir(const WCHAR *wfile)
|
||||||
{
|
{
|
||||||
struct stati64 st;
|
DWORD attr = GetFileAttributesW(wfile);
|
||||||
if (wstati64(wfile, &st) != 0 || !S_ISDIR(st.st_mode))
|
if (attr == (DWORD)-1L ||
|
||||||
|
!(attr & FILE_ATTRIBUTE_DIRECTORY) ||
|
||||||
|
check_valid_dir(wfile)) {
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
}
|
||||||
errno = EISDIR;
|
errno = EISDIR;
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user