File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -35,7 +35,7 @@ namespace PyExt::Remote {
3535 auto offset () const -> Offset;
3636 auto symbolName () const -> std::string;
3737 // necessary for x86 because offsets in remote address space are only 32 Bit
38- static auto readOffsetArray (/* const*/ ExtRemoteTyped& remoteArray, unsigned long numElements) -> std::vector<Offset>;
38+ static auto readOffsetArray (/* const*/ ExtRemoteTyped& remoteArray, std:: uint64_t numElements) -> std::vector<Offset>;
3939
4040 protected: // Helpers for more derived classes.
4141 // / Access to the instance's memory in the debuggee.
Original file line number Diff line number Diff line change 33#include < engextcpp.hpp>
44#include < type_traits>
55#include < vector>
6+ #include < string>
7+ #include < limits>
68using namespace std ::literals::string_literals;
79
810namespace utils {
@@ -31,16 +33,22 @@ namespace utils {
3133
3234 // Reads an array of elements pointed to by an ExtRemoteData.
3335 template <typename ElemType>
34- auto readArray (/* const*/ ExtRemoteTyped& remoteArray, unsigned long numElements) -> std::vector<ElemType>
36+ auto readArray (/* const*/ ExtRemoteTyped& remoteArray, std:: uint64_t numElements) -> std::vector<ElemType>
3537 {
3638 auto remoteData = remoteArray.Dereference ();
3739 const auto remoteSize = remoteData.GetTypeSize ();
3840 if (remoteSize != sizeof (ElemType)) {
3941 g_Ext->ThrowRemote (E_INVALIDARG, " sizeof(ElemType) does not match size type size for ExtRemoteTyped array read." );
4042 }
4143
44+ const auto arrayExtent = numElements * remoteSize;
45+ // ExtRemoteData only supports arrays with 32bit extents, so we have to narrow it.
46+ if (numElements > std::numeric_limits<std::uint32_t >::max ()) {
47+ g_Ext->ThrowRemote (E_BOUNDS, " Could not read array. Size too large." );
48+ }
49+
4250 std::vector<ElemType> buffer (numElements);
43- remoteData.ReadBuffer (buffer.data (), numElements*remoteSize );
51+ remoteData.ReadBuffer (buffer.data (), static_cast <std:: uint32_t >(arrayExtent) );
4452 return buffer;
4553 }
4654
Original file line number Diff line number Diff line change 6363 <PrecompiledHeaderFile >pch.h</PrecompiledHeaderFile >
6464 <ForcedIncludeFiles >pch.h</ForcedIncludeFiles >
6565 <LanguageStandard >stdcpp17</LanguageStandard >
66- <PreprocessorDefinitions >PYEXT_DLL;%(PreprocessorDefinitions)</PreprocessorDefinitions >
66+ <PreprocessorDefinitions >PYEXT_DLL;NOMINMAX; %(PreprocessorDefinitions)</PreprocessorDefinitions >
6767 </ClCompile >
6868 <Link >
6969 <SubSystem >Windows</SubSystem >
Original file line number Diff line number Diff line change @@ -51,7 +51,7 @@ namespace PyExt::Remote {
5151 }
5252
5353
54- auto RemoteType::readOffsetArray (/* const*/ ExtRemoteTyped& remoteArray, unsigned long numElements) -> vector<Offset>
54+ auto RemoteType::readOffsetArray (/* const*/ ExtRemoteTyped& remoteArray, std:: uint64_t numElements) -> vector<Offset>
5555 {
5656 auto ptrSize = utils::getPointerSize ();
5757 switch (ptrSize) {
@@ -63,7 +63,7 @@ namespace PyExt::Remote {
6363 }
6464 case 8 :
6565 // x64 - 64 Bit Python
66- return utils::readArray<Offset >(remoteArray, numElements);
66+ return utils::readArray<std:: uint64_t >(remoteArray, numElements);
6767 }
6868
6969 g_Ext->ThrowInterrupt ();
You can’t perform that action at this time.
0 commit comments