changeset 6323:8718da8c36f3

8009654: Improve stability of cmsnamed Reviewed-by: bae, prr Contributed-by: jia-hong.chen@oracle.com
author bae
date Fri, 29 Mar 2013 10:30:31 +0400
parents cc656d61e713
children 91ce9432f88d
files src/share/native/sun/java2d/cmm/lcms/cmsnamed.c
diffstat 1 files changed, 6 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/native/sun/java2d/cmm/lcms/cmsnamed.c	Thu Mar 28 14:59:22 2013 -0700
+++ b/src/share/native/sun/java2d/cmm/lcms/cmsnamed.c	Fri Mar 29 10:30:31 2013 +0400
@@ -517,9 +517,9 @@
     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 @@
     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