changeset 7418:185cbf454f51

8009654: Improve stability of cmsnamed Reviewed-by: bae, mschoene, prr Contributed-by: jia-hong.chen@oracle.com
author jgodinez
date Wed, 27 Mar 2013 11:38:46 -0700
parents 311f16954ada
children c193b7431ea6
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	Wed Mar 27 13:29:22 2013 +0100
+++ b/src/share/native/sun/java2d/cmm/lcms/cmsnamed.c	Wed Mar 27 11:38:46 2013 -0700
@@ -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