Skip to content

Commit 4f4dc7b

Browse files
committed
merge revision(s) 30905:
* lib/fileutils.rb (FileUtils::remove_entry_secure): there is a race condition in the case where the given path is a directory, and some other user can move that directory, and create a symlink while this method is executing. Reported by: Nicholas Jefferson <nicholas at pythonic.com.au> git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8_7@30910 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
1 parent e86bf2d commit 4f4dc7b

File tree

3 files changed

+18
-5
lines changed

3 files changed

+18
-5
lines changed

ChangeLog

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
Fri Feb 18 21:17:22 2011 Shugo Maeda <shugo@ruby-lang.org>
2+
3+
* lib/fileutils.rb (FileUtils::remove_entry_secure): there is a
4+
race condition in the case where the given path is a directory,
5+
and some other user can move that directory, and create a
6+
symlink while this method is executing.
7+
Reported by: Nicholas Jefferson <nicholas at pythonic.com.au>
8+
19
Fri Feb 18 19:46:46 2011 NAKAMURA Usaku <usa@ruby-lang.org>
210

311
* win32/win32.c (init_stdhandle): backport mistake of r29382.

lib/fileutils.rb

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -658,10 +658,10 @@ def rm_rf(list, options = {})
658658
# removing directories. This requires the current process is the
659659
# owner of the removing whole directory tree, or is the super user (root).
660660
#
661-
# WARNING: You must ensure that *ALL* parent directories are not
662-
# world writable. Otherwise this method does not work.
663-
# Only exception is temporary directory like /tmp and /var/tmp,
664-
# whose permission is 1777.
661+
# WARNING: You must ensure that *ALL* parent directories cannot be
662+
# moved by other untrusted users. For example, parent directories
663+
# should not be owned by untrusted users, and should not be world
664+
# writable except when the sticky bit set.
665665
#
666666
# WARNING: Only the owner of the removing directory tree, or Unix super
667667
# user (root) should invoke this method. Otherwise this method does not
@@ -704,6 +704,11 @@ def remove_entry_secure(path, force = false)
704704
end
705705
f.chown euid, -1
706706
f.chmod 0700
707+
unless fu_stat_identical_entry?(st, File.lstat(fullpath))
708+
# TOC-to-TOU attack?
709+
File.unlink fullpath
710+
return
711+
end
707712
}
708713
# ---- tree root is frozen ----
709714
root = Entry_.new(path)

version.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#define RUBY_RELEASE_DATE "2011-02-18"
33
#define RUBY_VERSION_CODE 187
44
#define RUBY_RELEASE_CODE 20110218
5-
#define RUBY_PATCHLEVEL 332
5+
#define RUBY_PATCHLEVEL 333
66

77
#define RUBY_VERSION_MAJOR 1
88
#define RUBY_VERSION_MINOR 8

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy