[vlc-commits] skins2: fix ToCToU

Rémi Denis-Courmont git at videolan.org
Thu Dec 31 15:16:43 CET 2015


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Thu Dec 31 16:16:26 2015 +0200| [4768fb3d6b84b5e90bce1b3e73d63a654a3b8b81] | committer: Rémi Denis-Courmont

skins2: fix ToCToU

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=4768fb3d6b84b5e90bce1b3e73d63a654a3b8b81
---

 modules/gui/skins2/x11/x11_factory.cpp |   10 ++--------
 1 file changed, 2 insertions(+), 8 deletions(-)

diff --git a/modules/gui/skins2/x11/x11_factory.cpp b/modules/gui/skins2/x11/x11_factory.cpp
index f7369a0..a5c4570 100644
--- a/modules/gui/skins2/x11/x11_factory.cpp
+++ b/modules/gui/skins2/x11/x11_factory.cpp
@@ -24,9 +24,9 @@
 
 #ifdef X11_SKINS
 
+#include <errno.h>
 #include <unistd.h>
 #include <dirent.h>
-#include <sys/stat.h>
 #include <X11/Xlib.h>
 #include <X11/extensions/Xinerama.h>
 
@@ -349,7 +349,6 @@ void X11Factory::rmDir( const std::string &rPath )
     // Parse the directory and remove everything it contains
     while( (file = readdir( dir )) )
     {
-        struct stat statbuf;
         std::string filename = file->d_name;
 
         // Skip "." and ".."
@@ -360,12 +359,7 @@ void X11Factory::rmDir( const std::string &rPath )
 
         filename = rPath + "/" + filename;
 
-        if( !stat( filename.c_str(), &statbuf ) && statbuf.st_mode & S_IFDIR )
-        {
-            rmDir( filename );
-        }
-        else
-        {
+        if( rmdir( filename.c_str() ) && errno == ENOTDIR )
             unlink( filename.c_str() );
         }
     }



More information about the vlc-commits mailing list