From f9b24b42bb739d0f10ec284e56cd28bb39e71fb4 Mon Sep 17 00:00:00 2001 From: Fedor Chelnokov Date: Mon, 2 Sep 2024 10:09:17 +0300 Subject: [PATCH] fromSceneE57File: check for too many points --- source/MRMesh/MRPointsLoadE57.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/source/MRMesh/MRPointsLoadE57.cpp b/source/MRMesh/MRPointsLoadE57.cpp index 4347d8db0cd0..c21e88f63625 100644 --- a/source/MRMesh/MRPointsLoadE57.cpp +++ b/source/MRMesh/MRPointsLoadE57.cpp @@ -6,6 +6,7 @@ #include "MRQuaternion.h" #include "MRTimer.h" #include +#include #pragma warning(push) #pragma warning(disable: 4251) // class needs to have dll-interface to be used by clients of another class @@ -84,6 +85,9 @@ Expected> fromSceneE57File( const std::filesystem::path& if ( !eReader.GetData3DSizes( scanIndex, nRow, nColumn, nPointsSize, nGroupsSize, nCountSize, bColumnIndex) ) return MR::unexpected( std::string( "GetData3DSizes failed during reading of " + utf8string( file ) ) ); + if ( nPointsSize > INT_MAX ) + return MR::unexpected( fmt::format( "Too many points {} in {}.\nMaximum supported is {}.", nPointsSize, utf8string( file ), INT_MAX ) ); + // how many points to read in a time const int64_t nSize = std::min( nPointsSize, int64_t( 1024 ) * 128 );