8009654: Improve stability of cmsnamed

Reviewed-by: bae, mschoene, prr
This commit is contained in:
Jia-Hong Chen 2013-03-27 11:38:46 -07:00 committed by Jennifer Godinez
parent dc1533f6cf
commit c5ed90b0bb

View File

@ -517,9 +517,9 @@ cmsNAMEDCOLORLIST* CMSEXPORT cmsAllocNamedColorList(cmsContext ContextID, cmsUIn
while (v -> Allocated < n) while (v -> Allocated < n)
GrowNamedColorList(v); GrowNamedColorList(v);
strncpy(v ->Prefix, Prefix, sizeof(v ->Prefix)); strncpy(v ->Prefix, Prefix, sizeof(v ->Prefix) - 1);
strncpy(v ->Suffix, Suffix, sizeof(v ->Suffix)); strncpy(v ->Suffix, Suffix, sizeof(v ->Suffix) - 1);
v->Prefix[32] = v->Suffix[32] = 0; v->Prefix[sizeof(v ->Prefix) - 1] = v->Suffix[sizeof(v ->Suffix) - 1] = 0;
v -> ColorantCount = ColorantCount; v -> ColorantCount = ColorantCount;
@ -577,9 +577,10 @@ cmsBool CMSEXPORT cmsAppendNamedColor(cmsNAMEDCOLORLIST* NamedColorList,
if (Name != NULL) { if (Name != NULL) {
strncpy(NamedColorList ->List[NamedColorList ->nColors].Name, Name, strncpy(NamedColorList ->List[NamedColorList ->nColors].Name, Name,
sizeof(NamedColorList ->List[NamedColorList ->nColors].Name)); sizeof(NamedColorList ->List[NamedColorList ->nColors].Name) - 1);
NamedColorList ->List[NamedColorList ->nColors].Name[cmsMAX_PATH-1] = 0; NamedColorList ->List[NamedColorList ->nColors].
Name[sizeof(NamedColorList ->List[NamedColorList ->nColors].Name) - 1] = 0;
} }
else else