зеркало из https://github.com/github/ruby.git
* 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:
Родитель
06fba52338
Коммит
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>
|
||||
|
||||
* 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
|
||||
if ((fd = rb_cloexec_open(fname, mode, 0)) < 0) {
|
||||
load_failed:
|
||||
rb_load_fail(fname_v, strerror(errno));
|
||||
}
|
||||
rb_update_max_fd(fd);
|
||||
#if !defined DOSISH && !defined __CYGWIN__
|
||||
{
|
||||
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)) {
|
||||
errno = EISDIR;
|
||||
goto load_failed;
|
||||
rb_load_fail(fname_v, strerror(EISDIR));
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
f = rb_io_fdopen(fd, mode, fname);
|
||||
}
|
||||
|
||||
|
|
|
@ -5188,9 +5188,18 @@ rb_w32_uopen(const char *file, int oflag, ...)
|
|||
static int
|
||||
check_if_dir(const char *file)
|
||||
{
|
||||
struct stati64 st;
|
||||
if (rb_w32_stati64(file, &st) != 0 || !S_ISDIR(st.st_mode))
|
||||
DWORD attr;
|
||||
WCHAR *wfile;
|
||||
|
||||
if (!(wfile = filecp_to_wstr(file, NULL)))
|
||||
return FALSE;
|
||||
attr = GetFileAttributesW(wfile);
|
||||
if (attr == (DWORD)-1L ||
|
||||
!(attr & FILE_ATTRIBUTE_DIRECTORY) ||
|
||||
check_valid_dir(wfile)) {
|
||||
return FALSE;
|
||||
}
|
||||
free(wfile);
|
||||
errno = EISDIR;
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -5199,9 +5208,12 @@ check_if_dir(const char *file)
|
|||
static int
|
||||
check_if_wdir(const WCHAR *wfile)
|
||||
{
|
||||
struct stati64 st;
|
||||
if (wstati64(wfile, &st) != 0 || !S_ISDIR(st.st_mode))
|
||||
DWORD attr = GetFileAttributesW(wfile);
|
||||
if (attr == (DWORD)-1L ||
|
||||
!(attr & FILE_ATTRIBUTE_DIRECTORY) ||
|
||||
check_valid_dir(wfile)) {
|
||||
return FALSE;
|
||||
}
|
||||
errno = EISDIR;
|
||||
return TRUE;
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче