[systemd-commits] src/util.c

Michal Schmidt michich at kemper.freedesktop.org
Fri Mar 16 10:35:46 PDT 2012


 src/util.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

New commits:
commit 5ebff5337594d690b322078c512eb222d34aaa82
Author: Michal Schmidt <mschmidt at redhat.com>
Date:   Fri Mar 2 10:39:10 2012 +0100

    util: never follow symlinks in rm_rf_children()
    
    The function checks if the entry is a directory before recursing, but
    there is a window between the check and the open, during which the
    directory could be replaced with a symlink.
    
    CVE-2012-1174
    https://bugzilla.redhat.com/show_bug.cgi?id=803358

diff --git a/src/util.c b/src/util.c
index 20cbc2b..dfc1dc6 100644
--- a/src/util.c
+++ b/src/util.c
@@ -3593,7 +3593,8 @@ static int rm_rf_children(int fd, bool only_dirs, bool honour_sticky) {
                 if (is_dir) {
                         int subdir_fd;
 
-                        if ((subdir_fd = openat(fd, de->d_name, O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC)) < 0) {
+                        subdir_fd = openat(fd, de->d_name, O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC|O_NOFOLLOW);
+                        if (subdir_fd < 0) {
                                 if (ret == 0 && errno != ENOENT)
                                         ret = -errno;
                                 continue;



More information about the systemd-commits mailing list