diff options
author | Marti Maria <info@littlecms.com> | 2013-06-25 16:09:16 +0200 |
---|---|---|
committer | Marti Maria <info@littlecms.com> | 2013-06-25 16:09:16 +0200 |
commit | 91c2db7f2559be504211b283bc3a2c631d6f06d9 (patch) | |
tree | bf56bb78b1aefe0ff89f7a982b7b762d47a2a505 | |
parent | 0ba8f90dc60be8e838556ceb31474f1f407967dd (diff) | |
download | lcms2-91c2db7f2559be504211b283bc3a2c631d6f06d9.tar.gz |
Non happy-path fixes
-rw-r--r-- | ChangeLog | 1 | ||||
-rw-r--r-- | src/cmsnamed.c | 12 | ||||
-rw-r--r-- | src/cmsopt.c | 10 |
3 files changed, 18 insertions, 5 deletions
@@ -120,6 +120,7 @@ Added support for VS2012 Added a simple project for cppcheck Rendering intent used when creating the transform is now propagated to profile header in cmsTransform2Devicelink. This is because 7.2.15 in spec 4.3 Transform2Devicelink now keeps white point when guessing deviceclass is enabled +Added some checks for non-happy path, mostly failing mallocs ----------------------- 2.5 Maintenance release diff --git a/src/cmsnamed.c b/src/cmsnamed.c index a916e17..acfd1c8 100644 --- a/src/cmsnamed.c +++ b/src/cmsnamed.c @@ -517,8 +517,8 @@ cmsNAMEDCOLORLIST* CMSEXPORT cmsAllocNamedColorList(cmsContext ContextID, cmsUIn while (v -> Allocated < n) GrowNamedColorList(v); - strncpy(v ->Prefix, Prefix, sizeof(v ->Prefix)); - strncpy(v ->Suffix, Suffix, sizeof(v ->Suffix)); + strncpy(v ->Prefix, Prefix, sizeof(v ->Prefix)-1); + strncpy(v ->Suffix, Suffix, sizeof(v ->Suffix)-1); v->Prefix[32] = v->Suffix[32] = 0; v -> ColorantCount = ColorantCount; @@ -577,9 +577,7 @@ cmsBool CMSEXPORT cmsAppendNamedColor(cmsNAMEDCOLORLIST* NamedColorList, if (Name != NULL) { - strncpy(NamedColorList ->List[NamedColorList ->nColors].Name, Name, - sizeof(NamedColorList ->List[NamedColorList ->nColors].Name)); - + strncpy(NamedColorList ->List[NamedColorList ->nColors].Name, Name, cmsMAX_PATH-1); NamedColorList ->List[NamedColorList ->nColors].Name[cmsMAX_PATH-1] = 0; } @@ -735,6 +733,10 @@ cmsSEQ* CMSEXPORT cmsAllocProfileSequenceDescription(cmsContext ContextID, cmsUI Seq -> seq = (cmsPSEQDESC*) _cmsCalloc(ContextID, n, sizeof(cmsPSEQDESC)); Seq -> n = n; + if (Seq -> seq == NULL) { + _cmsFree(ContextID, Seq); + return NULL; + } for (i=0; i < n; i++) { Seq -> seq[i].Manufacturer = NULL; diff --git a/src/cmsopt.c b/src/cmsopt.c index 7478e5e..4bdf0a7 100644 --- a/src/cmsopt.c +++ b/src/cmsopt.c @@ -1179,6 +1179,16 @@ Curves16Data* CurvesAlloc(cmsContext ContextID, int nCurves, int nElements, cmsT c16->Curves[i] = _cmsCalloc(ContextID, nElements, sizeof(cmsUInt16Number)); + if (c16->Curves[i] == NULL) { + + for (j=0; j < i; j++) { + _cmsFree(ContextID, c16->Curves[j]); + } + _cmsFree(ContextID, c16->Curves); + _cmsFree(ContextID, c16); + return NULL; + } + if (nElements == 256) { for (j=0; j < nElements; j++) { |