summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarti Maria <info@littlecms.com>2011-02-15 15:44:49 +0100
committerMarti Maria <info@littlecms.com>2011-02-15 15:44:49 +0100
commite06c51f04a41bb999f7c083b1771dca1923aad71 (patch)
tree1e30366589bc0bc39197da812d46dc08292ca356
parenta96dc5a6011e2bc6bc73c39ac5560f0461ab8fbd (diff)
downloadlcms2-e06c51f04a41bb999f7c083b1771dca1923aad71.tar.gz
Several fixups
-rw-r--r--ChangeLog5
-rw-r--r--src/cmsio0.c11
-rw-r--r--src/cmsio1.c6
-rw-r--r--src/cmslut.c9
-rw-r--r--src/cmsps2.c7
-rw-r--r--src/cmssm.c4
6 files changed, 31 insertions, 11 deletions
diff --git a/ChangeLog b/ChangeLog
index e9d3bf9..53ad5da 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -28,4 +28,7 @@ Added bound check in floating point interpolation
-----------------------
Fixed severa bugs in absolute colorimetric intent
-Removed pthreads need \ No newline at end of file
+Removed pthreads need
+Updated linkicc to 2.1, cleanup
+Fixed some potential issues as NULL dereferencing
+Fixed GBD bug (out of bounds memory overwrite)
diff --git a/src/cmsio0.c b/src/cmsio0.c
index f5d5d47..5553a65 100644
--- a/src/cmsio0.c
+++ b/src/cmsio0.c
@@ -1,7 +1,7 @@
//---------------------------------------------------------------------------------
//
// Little Color Management System
-// Copyright (c) 1998-2010 Marti Maria Saguer
+// Copyright (c) 1998-2011 Marti Maria Saguer
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the "Software"),
@@ -1649,11 +1649,18 @@ cmsInt32Number CMSEXPORT cmsReadRawTag(cmsHPROFILE hProfile, cmsTagSignature sig
// Obtain type handling for the tag
TypeHandler = Icc ->TagTypeHandlers[i];
TagDescriptor = _cmsGetTagDescriptor(sig);
+ if (TagDescriptor == NULL) {
+ cmsCloseIOhandler(MemIO);
+ return 0;
+ }
// Serialize
TypeHandler ->ContextID = Icc ->ContextID;
TypeHandler ->ICCVersion = Icc ->Version;
- if (!TypeHandler ->WritePtr(TypeHandler, MemIO, Object, TagDescriptor ->ElemCount)) return 0;
+ if (!TypeHandler ->WritePtr(TypeHandler, MemIO, Object, TagDescriptor ->ElemCount)) {
+ cmsCloseIOhandler(MemIO);
+ return 0;
+ }
// Get Size and close
rc = MemIO ->Tell(MemIO);
diff --git a/src/cmsio1.c b/src/cmsio1.c
index c93eaa8..b575730 100644
--- a/src/cmsio1.c
+++ b/src/cmsio1.c
@@ -1,7 +1,7 @@
//---------------------------------------------------------------------------------
//
// Little Color Management System
-// Copyright (c) 1998-2010 Marti Maria Saguer
+// Copyright (c) 1998-2011 Marti Maria Saguer
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the "Software"),
@@ -611,7 +611,6 @@ cmsBool CMSEXPORT cmsIsIntentSupported(cmsHPROFILE hProfile,
// Read both, profile sequence description and profile sequence id if present. Then combine both to
// create qa unique structure holding both. Shame on ICC to store things in such complicated way.
-
cmsSEQ* _cmsReadProfileSequence(cmsHPROFILE hProfile)
{
cmsSEQ* ProfileSeq;
@@ -636,12 +635,13 @@ cmsSEQ* _cmsReadProfileSequence(cmsHPROFILE hProfile)
NewSeq = cmsDupProfileSequenceDescription(ProfileSeq);
// Ok, proceed to the mixing
+ if (NewSeq != NULL) {
for (i=0; i < ProfileSeq ->n; i++) {
memmove(&NewSeq ->seq[i].ProfileID, &ProfileId ->seq[i].ProfileID, sizeof(cmsProfileID));
NewSeq ->seq[i].Description = cmsMLUdup(ProfileId ->seq[i].Description);
}
-
+ }
return NewSeq;
}
diff --git a/src/cmslut.c b/src/cmslut.c
index ab2a950..772c110 100644
--- a/src/cmslut.c
+++ b/src/cmslut.c
@@ -1,7 +1,7 @@
//---------------------------------------------------------------------------------
//
// Little Color Management System
-// Copyright (c) 1998-2010 Marti Maria Saguer
+// Copyright (c) 1998-2011 Marti Maria Saguer
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the "Software"),
@@ -732,8 +732,13 @@ cmsBool CMSEXPORT cmsStageSampleCLut16bit(cmsStage* mpe, cmsSAMPLER16 Sampler, v
int nInputs, nOutputs;
cmsUInt32Number* nSamples;
cmsUInt16Number In[cmsMAXCHANNELS], Out[MAX_STAGE_CHANNELS];
- _cmsStageCLutData* clut = (_cmsStageCLutData*) mpe->Data;
+ _cmsStageCLutData* clut;
+
+ if (mpe == NULL) return FALSE;
+
+ clut = (_cmsStageCLutData*) mpe->Data;
+ if (clut == NULL) return FALSE;
nSamples = clut->Params ->nSamples;
nInputs = clut->Params ->nInputs;
diff --git a/src/cmsps2.c b/src/cmsps2.c
index b41f58f..250e047 100644
--- a/src/cmsps2.c
+++ b/src/cmsps2.c
@@ -1,7 +1,7 @@
//---------------------------------------------------------------------------------
//
// Little Color Management System
-// Copyright (c) 1998-2008 Marti Maria Saguer
+// Copyright (c) 1998-2011 Marti Maria Saguer
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the "Software"),
@@ -469,6 +469,7 @@ void Emit1Gamma(cmsIOHANDLER* m, cmsToneCurve* Table)
cmsUInt32Number i;
cmsFloat64Number gamma;
+ if (Table == NULL) return; // Error
if (Table ->nEntries <= 0) return; // Empty table
@@ -548,6 +549,8 @@ void EmitNGamma(cmsIOHANDLER* m, int n, cmsToneCurve* g[])
for( i=0; i < n; i++ )
{
+ if (g[i] == NULL) return; // Error
+
if (i > 0 && GammaTableEquals(g[i-1]->Table16, g[i]->Table16, g[i]->nEntries)) {
_cmsIOPrintf(m, "dup ");
@@ -836,6 +839,7 @@ cmsToneCurve* ExtractGray2Y(cmsContext ContextID, cmsHPROFILE hProfile, int Inte
cmsHTRANSFORM xform = cmsCreateTransformTHR(ContextID, hProfile, TYPE_GRAY_8, hXYZ, TYPE_XYZ_DBL, Intent, cmsFLAGS_NOOPTIMIZE);
int i;
+ if (Out != NULL) {
for (i=0; i < 256; i++) {
cmsUInt8Number Gray = (cmsUInt8Number) i;
@@ -845,6 +849,7 @@ cmsToneCurve* ExtractGray2Y(cmsContext ContextID, cmsHPROFILE hProfile, int Inte
Out ->Table16[i] =_cmsQuickSaturateWord(XYZ.Y * 65535.0);
}
+ }
cmsDeleteTransform(xform);
cmsCloseProfile(hXYZ);
diff --git a/src/cmssm.c b/src/cmssm.c
index e5a6b0d..5f11180 100644
--- a/src/cmssm.c
+++ b/src/cmssm.c
@@ -1,7 +1,7 @@
//---------------------------------------------------------------------------------
//
// Little Color Management System
-// Copyright (c) 1998-2010 Marti Maria Saguer
+// Copyright (c) 1998-2011 Marti Maria Saguer
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the "Software"),
@@ -476,7 +476,7 @@ cmsBool InterpolateMissingSector(cmsGDB* gbd, int alpha, int theta)
cmsVEC3 Centre;
cmsLine ray;
int nCloseSectors;
- cmsGDBPoint* Close[NSTEPS];
+ cmsGDBPoint* Close[NSTEPS + 1];
cmsSpherical closel, templ;
cmsLine edge;
int k, m;