1
0
mirror of https://github.com/opencv/opencv.git synced 2026-07-21 19:33:03 +04:00

Merge pull request #29271 from uwezkhan:torch-storage-size-cap

cap torch storage size to int to prevent heap overflow
This commit is contained in:
Alexander Smorkalov
2026-06-09 12:49:17 +03:00
committed by GitHub
+4
View File
@@ -255,6 +255,10 @@ struct TorchImporter
void readTorchStorage(int index, int type = -1)
{
long size = readLong();
// size is read as a 64-bit value but Mat::create() takes int columns, so a
// value above INT_MAX is truncated for the allocation while the THFile_read*Raw
// calls below still consume the full 64-bit count, overflowing the buffer.
CV_Assert(size >= 0 && size <= INT_MAX);
Mat storageMat;
switch (type)