From c5ed90b0bb3d74d55816fd99cf8b6e6b8566817a Mon Sep 17 00:00:00 2001 From: Jia-Hong Chen Date: Wed, 27 Mar 2013 11:38:46 -0700 Subject: [PATCH] 8009654: Improve stability of cmsnamed Reviewed-by: bae, mschoene, prr --- jdk/src/share/native/sun/java2d/cmm/lcms/cmsnamed.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/jdk/src/share/native/sun/java2d/cmm/lcms/cmsnamed.c b/jdk/src/share/native/sun/java2d/cmm/lcms/cmsnamed.c index 53bcdf9643e..de4a0fd1f06 100644 --- a/jdk/src/share/native/sun/java2d/cmm/lcms/cmsnamed.c +++ b/jdk/src/share/native/sun/java2d/cmm/lcms/cmsnamed.c @@ -517,9 +517,9 @@ 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)); - v->Prefix[32] = v->Suffix[32] = 0; + strncpy(v ->Prefix, Prefix, sizeof(v ->Prefix) - 1); + strncpy(v ->Suffix, Suffix, sizeof(v ->Suffix) - 1); + v->Prefix[sizeof(v ->Prefix) - 1] = v->Suffix[sizeof(v ->Suffix) - 1] = 0; v -> ColorantCount = ColorantCount; @@ -577,9 +577,10 @@ cmsBool CMSEXPORT cmsAppendNamedColor(cmsNAMEDCOLORLIST* NamedColorList, if (Name != NULL) { 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