#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

@@ -8,9 +8,12 @@
#include <gtest/gtest.h>
#include <filesystem>
#include <fstream>
#include <memory>
#include <vector>
#include <QTemporaryDir>
// Test importing a VTU file
TEST( RifVtkSurfaceImporterTest, ImportFromFile )
{
@@ -52,6 +55,45 @@ TEST( RifVtkSurfaceImporterTest, ImportFromFile )
}
}
// Connectivity referring to a non-existing vertex used to read outside the vertex array
TEST( RifVtkSurfaceImporterTest, ConnectivityOutOfRangeIsRejected )
{
const std::string xml = R"(<?xml version="1.0"?>
<VTKFile type="UnstructuredGrid" version="1.0">
<UnstructuredGrid>
<Piece NumberOfPoints="3" NumberOfCells="1">
<Points>
<DataArray type="Float64" Name="Coordinates" NumberOfComponents="3">0 0 0 1 0 0 0 1 0</DataArray>
</Points>
<Cells>
<DataArray type="UInt32" Name="connectivity">100000000 1 2</DataArray>
<DataArray type="UInt32" Name="offsets">3</DataArray>
<DataArray type="UInt8" Name="types">5</DataArray>
</Cells>
</Piece>
</UnstructuredGrid>
</VTKFile>)";
QTemporaryDir tempDir;
ASSERT_TRUE( tempDir.isValid() );
const auto filePath = std::filesystem::path( tempDir.path().toStdString() ) / "surface.vtu";
auto writeFile = [&filePath]( const std::string& content )
{
std::ofstream out( filePath );
out << content;
};
writeFile( xml );
EXPECT_EQ( nullptr, RifVtkSurfaceImporter::importFromFile( filePath ) );
// The same file with valid indices is accepted
auto validXml = xml;
validXml.replace( validXml.find( "100000000" ), 9, "0" );
writeFile( validXml );
EXPECT_NE( nullptr, RifVtkSurfaceImporter::importFromFile( filePath ) );
}
// Test parsing a PVD file
TEST( RifVtkSurfaceImporterTest, ParsePvdDatasets )
{