1
0
mirror of https://github.com/opencv/opencv.git synced 2026-07-29 15:23:05 +04:00

cap torch storage size to int to prevent heap overflow

This commit is contained in:
uwezkhan
2026-06-09 10:09:52 +05:30
parent 6f29af625b
commit fe61ae0e41
+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)