Author: cwittich
Date: Wed Jul 25 19:11:06 2007
New Revision: 27810
URL:
http://svn.reactos.org/svn/reactos?rev=27810&view=rev
Log:
-fix an endless loop when a rbuild file has an invalid date
See issue #2466 for more details.
Modified:
trunk/reactos/tools/rbuild/backend/mingw/mingw.cpp
trunk/reactos/tools/rbuild/exception.cpp
trunk/reactos/tools/rbuild/exception.h
Modified: trunk/reactos/tools/rbuild/backend/mingw/mingw.cpp
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/tools/rbuild/backend/mingw…
==============================================================================
--- trunk/reactos/tools/rbuild/backend/mingw/mingw.cpp (original)
+++ trunk/reactos/tools/rbuild/backend/mingw/mingw.cpp Wed Jul 25 19:11:06 2007
@@ -522,6 +522,9 @@
ProjectNode.GetProjectFilename ().c_str () );
string xmlbuildFilenames;
int numberOfExistingFiles = 0;
+ struct stat statbuf;
+ time_t SystemTime, lastWriteTime;
+
for ( size_t i = 0; i < ProjectNode.xmlbuildfiles.size (); i++ )
{
XMLInclude& xmlbuildfile = *ProjectNode.xmlbuildfiles[i];
@@ -530,6 +533,28 @@
numberOfExistingFiles++;
if ( xmlbuildFilenames.length () > 0 )
xmlbuildFilenames += " ";
+
+ FILE* f = fopen ( xmlbuildfile.topIncludeFilename.c_str (), "rb" );
+ if ( !f )
+ throw FileNotFoundException ( NormalizeFilename ( xmlbuildfile.topIncludeFilename ) );
+
+ if ( fstat ( fileno ( f ), &statbuf ) != 0 )
+ {
+ fclose ( f );
+ throw AccessDeniedException ( NormalizeFilename ( xmlbuildfile.topIncludeFilename )
);
+ }
+
+ lastWriteTime = statbuf.st_mtime;
+ SystemTime = time(NULL);
+
+ if (SystemTime != -1)
+ {
+ if (difftime (lastWriteTime, SystemTime) > 0)
+ throw InvalidDateException ( NormalizeFilename ( xmlbuildfile.topIncludeFilename )
);
+ }
+
+ fclose ( f );
+
xmlbuildFilenames += NormalizeFilename ( xmlbuildfile.topIncludeFilename );
if ( numberOfExistingFiles % 5 == 4 || i == ProjectNode.xmlbuildfiles.size () - 1 )
{
Modified: trunk/reactos/tools/rbuild/exception.cpp
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/tools/rbuild/exception.cpp…
==============================================================================
--- trunk/reactos/tools/rbuild/exception.cpp (original)
+++ trunk/reactos/tools/rbuild/exception.cpp Wed Jul 25 19:11:06 2007
@@ -62,6 +62,13 @@
const int linenumber )
: Exception ( "%s:%d", filename, linenumber )
{
+}
+
+InvalidDateException::InvalidDateException ( const string& filename)
+ : Exception ( "File '%s' has an invalid date.",
+ filename.c_str() )
+{
+ Filename = filename;
}
InvalidOperationException::InvalidOperationException (
Modified: trunk/reactos/tools/rbuild/exception.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/tools/rbuild/exception.h?r…
==============================================================================
--- trunk/reactos/tools/rbuild/exception.h (original)
+++ trunk/reactos/tools/rbuild/exception.h Wed Jul 25 19:11:06 2007
@@ -73,6 +73,12 @@
std::string Filename;
};
+class InvalidDateException : public Exception
+{
+public:
+ InvalidDateException ( const std::string& filename );
+ std::string Filename;
+};
class RequiredAttributeNotFoundException : public XMLInvalidBuildFileException
{