A new user interface for you! Read more...

File lcms2-cgats-memory-allocation.patch of Package lcms2

Partial patch.
From 768f70ca405cd3159d990e962d54456773bb8cf8 Mon Sep 17 00:00:00 2001
From: Marti Maria <info@littlecms.com>
Date: Wed, 15 Aug 2018 20:07:56 +0200
Subject: [PATCH] Upgrade Visual studio 2017 15.8

...
- Add check on CGATS memory allocation (thanks to Quang Nguyen for
pointing out this)
---
 Projects/VC2017/jpegicc/jpegicc.vcxproj           |  1 +
 Projects/VC2017/lcms2_DLL/lcms2_DLL.vcxproj       |  2 +-
 Projects/VC2017/lcms2_static/lcms2_static.vcxproj |  2 +-
 Projects/VC2017/linkicc/linkicc.vcxproj           |  2 +-
 Projects/VC2017/psicc/psicc.vcxproj               |  2 +-
 Projects/VC2017/testbed/testbed.vcxproj           |  2 +-
 Projects/VC2017/tiffdiff/tiffdiff.vcxproj         |  2 +-
 Projects/VC2017/tifficc/tifficc.vcxproj           |  2 +-
 Projects/VC2017/transicc/transicc.vcxproj         |  1 +
 src/cmscgats.c                                    | 14 ++++++++++----
 10 files changed, 19 insertions(+), 11 deletions(-)

diff --git a/src/cmscgats.c b/src/cmscgats.c
index 1a87613..8c3e96d 100644
--- a/src/cmscgats.c
+++ b/src/cmscgats.c
@@ -1506,10 +1506,16 @@ void AllocateDataSet(cmsIT8* it8)
     t-> nSamples   = atoi(cmsIT8GetProperty(it8, "NUMBER_OF_FIELDS"));
     t-> nPatches   = atoi(cmsIT8GetProperty(it8, "NUMBER_OF_SETS"));
 
-    t-> Data = (char**)AllocChunk (it8, ((cmsUInt32Number) t->nSamples + 1) * ((cmsUInt32Number) t->nPatches + 1) *sizeof (char*));
-    if (t->Data == NULL) {
+    if (t -> nSamples < 0 || t->nSamples > 0x7ffe || t->nPatches < 0 || t->nPatches > 0x7ffe)
+    {
+        SynError(it8, "AllocateDataSet: too much data");
+    }
+    else {
+        t->Data = (char**)AllocChunk(it8, ((cmsUInt32Number)t->nSamples + 1) * ((cmsUInt32Number)t->nPatches + 1) * sizeof(char*));
+        if (t->Data == NULL) {
 
-        SynError(it8, "AllocateDataSet: Unable to allocate data array");
+            SynError(it8, "AllocateDataSet: Unable to allocate data array");
+        }
     }
 
 }
-- 
2.19.0