#14895: Improve stability when importing malformed input files

* #14895: Fix null grid dereference when importing mismatching GRDECL
* #14895: Fix out-of-bounds read in perforation interval import
* #14895: Validate connectivity indices in VTK import
* #14895: Fix heap overflow for odd PORV count in dual porosity cases
* #14895: Update roffcpp to validate array lengths when parsing ROFF files
This commit is contained in:
Magne Sjaastad authored and GitHub committed 2026-10-12 09:40:23 +02:00
1 parent 780af47317
commit ab96c520bd
10 files changed
+208 -6

No files matched your search

@@ -843,6 +843,55 @@ TEST( RifEclipseInputFileToolsTest, ExportGridInvalidParams )
EXPECT_FALSE( exportSuccess ) << "Should fail when passing nullptr eclipseCase";
}
//--------------------------------------------------------------------------------------------------
/// ZCORN size does not match SPECGRID. Used to dereference a null grid and crash.
//--------------------------------------------------------------------------------------------------
TEST( RifEclipseInputFileToolsTest, OpenGridFileWithMismatchingZcornSize )
{
QTemporaryDir tempDir;
ASSERT_TRUE( tempDir.isValid() );
QString fileName = tempDir.path() + "/mismatch.grdecl";
{
QFile file( fileName );
ASSERT_TRUE( file.open( QIODevice::WriteOnly | QIODevice::Text ) );
QTextStream out( &file );
out << "SPECGRID\n 10 10 10 1 F\n/\n\nCOORD\n";
for ( int i = 0; i < 726; i++ )
out << "1.0 ";
out << "\n/\n\nZCORN\n 1.0 1.0 1.0 1.0\n/\n";
}
auto eclipseCase = std::make_unique<RigEclipseCaseData>( nullptr );
QString errorMessages;
bool success = RifEclipseInputFileTools::openGridFile( fileName, eclipseCase.get(), false, &errorMessages );
EXPECT_FALSE( success );
}
//--------------------------------------------------------------------------------------------------
/// SPECGRID with too few values. Used to read outside the keyword data.
//--------------------------------------------------------------------------------------------------
TEST( RifEclipseInputFileToolsTest, OpenGridFileWithShortSpecgrid )
{
QTemporaryDir tempDir;
ASSERT_TRUE( tempDir.isValid() );
QString fileName = tempDir.path() + "/short_specgrid.grdecl";
{
QFile file( fileName );
ASSERT_TRUE( file.open( QIODevice::WriteOnly | QIODevice::Text ) );
QTextStream out( &file );
out << "SPECGRID\n 1\n/\n\nCOORD\n 0 0 0 0 0 1 1 0 0 1 0 1 0 1 0 0 1 1 1 1 0 1 1 1\n/\n\nZCORN\n 0 0 0 0 1 1 1 1\n/\n";
}
auto eclipseCase = std::make_unique<RigEclipseCaseData>( nullptr );
QString errorMessages;
bool success = RifEclipseInputFileTools::openGridFile( fileName, eclipseCase.get(), false, &errorMessages );
EXPECT_FALSE( success );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------