mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* util.c (valid_filename): use O_EXCL to get rid of clobbering
existing files in race conditions. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@15586 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
350e8342f9
commit
97dc8ee216
3 changed files with 13 additions and 12 deletions
|
|
@ -1,3 +1,8 @@
|
|||
Sun Feb 24 03:52:58 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* util.c (valid_filename): use O_EXCL to get rid of clobbering
|
||||
existing files in race conditions.
|
||||
|
||||
Fri Feb 22 19:50:19 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* bignum.c (BIGZEROP): fix for longer Bignum zeros. [ruby-Bugs-17454]
|
||||
|
|
|
|||
14
util.c
14
util.c
|
|
@ -233,23 +233,19 @@ valid_filename(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
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
#define RUBY_VERSION "1.8.6"
|
||||
#define RUBY_RELEASE_DATE "2008-02-22"
|
||||
#define RUBY_RELEASE_DATE "2008-02-24"
|
||||
#define RUBY_VERSION_CODE 186
|
||||
#define RUBY_RELEASE_CODE 20080222
|
||||
#define RUBY_RELEASE_CODE 20080224
|
||||
#define RUBY_PATCHLEVEL 5000
|
||||
|
||||
#define RUBY_VERSION_MAJOR 1
|
||||
|
|
@ -9,7 +9,7 @@
|
|||
#define RUBY_VERSION_TEENY 6
|
||||
#define RUBY_RELEASE_YEAR 2008
|
||||
#define RUBY_RELEASE_MONTH 2
|
||||
#define RUBY_RELEASE_DAY 22
|
||||
#define RUBY_RELEASE_DAY 24
|
||||
|
||||
#ifdef RUBY_EXTERN
|
||||
RUBY_EXTERN const char ruby_version[];
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue