mirror of
https://github.com/reactos/reactos.git
synced 2024-11-20 06:15:26 +00:00
-fix an endless loop when a rbuild file has an invalid date
See issue #2466 for more details. svn path=/trunk/; revision=27810
This commit is contained in:
parent
df43dc0653
commit
a7b34c7f12
3 changed files with 38 additions and 0 deletions
|
@ -522,6 +522,9 @@ MingwBackend::GenerateXmlBuildFilesMacro() const
|
|||
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 @@ MingwBackend::GenerateXmlBuildFilesMacro() const
|
|||
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 )
|
||||
{
|
||||
|
|
|
@ -64,6 +64,13 @@ InvalidOperationException::InvalidOperationException (
|
|||
{
|
||||
}
|
||||
|
||||
InvalidDateException::InvalidDateException ( const string& filename)
|
||||
: Exception ( "File '%s' has an invalid date.",
|
||||
filename.c_str() )
|
||||
{
|
||||
Filename = filename;
|
||||
}
|
||||
|
||||
InvalidOperationException::InvalidOperationException (
|
||||
const char* filename,
|
||||
const int linenumber,
|
||||
|
|
|
@ -73,6 +73,12 @@ public:
|
|||
std::string Filename;
|
||||
};
|
||||
|
||||
class InvalidDateException : public Exception
|
||||
{
|
||||
public:
|
||||
InvalidDateException ( const std::string& filename );
|
||||
std::string Filename;
|
||||
};
|
||||
|
||||
class RequiredAttributeNotFoundException : public XMLInvalidBuildFileException
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue