diff --git a/ChangeLog b/ChangeLog index f1d2cd6c13..53a4349bf4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Sun Feb 24 03:52:58 2008 Nobuyoshi Nakada + + * util.c (valid_filename): use O_EXCL to get rid of clobbering + existing files in race conditions. + Sat Feb 23 21:36:13 2008 NAKAMURA Usaku * ext/win32ole/win32ole.c (ole_init_cp): should return value. diff --git a/util.c b/util.c index 8a00aedf60..136ff1b213 100644 --- a/util.c +++ b/util.c @@ -345,23 +345,19 @@ valid_filename(const char *s) { int fd; - /* - // if the file exists, then it's a valid filename! - */ - - if (_access(s, 0) == 0) { - return 1; - } - /* // It doesn't exist, so see if we can open it. */ - if ((fd = _open(s, O_CREAT, 0666)) >= 0) { + if ((fd = _open(s, O_CREAT|O_EXCL, 0666)) >= 0) { _close(fd); _unlink(s); /* don't leave it laying around */ return 1; } + else if (errno == EEXIST) { + /* if the file exists, then it's a valid filename! */ + return 1; + } return 0; } #endif diff --git a/version.h b/version.h index 298cbfea85..3924c3dd53 100644 --- a/version.h +++ b/version.h @@ -1,7 +1,7 @@ #define RUBY_VERSION "1.9.0" -#define RUBY_RELEASE_DATE "2008-02-23" +#define RUBY_RELEASE_DATE "2008-02-24" #define RUBY_VERSION_CODE 190 -#define RUBY_RELEASE_CODE 20080223 +#define RUBY_RELEASE_CODE 20080224 #define RUBY_PATCHLEVEL 0 #define RUBY_VERSION_MAJOR 1 @@ -9,7 +9,7 @@ #define RUBY_VERSION_TEENY 0 #define RUBY_RELEASE_YEAR 2008 #define RUBY_RELEASE_MONTH 2 -#define RUBY_RELEASE_DAY 23 +#define RUBY_RELEASE_DAY 24 #ifdef RUBY_EXTERN RUBY_EXTERN const char ruby_version[];