changeset 106694:7874e9166ee3

Fix buffer overflow in ns_get_color. * nsterm.m (ns_get_color): Fix buffer overflow (Bug#4763).
author Chong Yidong <cyd@stupidchicken.com>
date Fri, 01 Jan 2010 17:10:50 -0500
parents 5240a1bf44bc
children a05636ead18a fa5a670f0c78
files src/ChangeLog src/nsterm.m
diffstat 2 files changed, 4 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/ChangeLog	Fri Jan 01 15:42:22 2010 -0500
+++ b/src/ChangeLog	Fri Jan 01 17:10:50 2010 -0500
@@ -1,5 +1,7 @@
 2010-01-01  Chong Yidong  <cyd@stupidchicken.com>
 
+	* nsterm.m (ns_get_color): Fix buffer overflow (Bug#4763).
+
 	* lread.c (syms_of_lread): Make it clearer that these are the
 	names of loaded files (Bug#5068).
 
--- a/src/nsterm.m	Fri Jan 01 15:42:22 2010 -0500
+++ b/src/nsterm.m	Fri Jan 01 17:10:50 2010 -0500
@@ -1346,7 +1346,8 @@
     }
   else if (!strncmp(name, "rgb:", 4))  /* A newer X11 format -- rgb:r/g/b */
     {
-      strcpy(hex, name + 4);
+      strncpy (hex, name + 4, 19);
+      hex[19] = '\0';
       scaling = (strlen(hex) - 2) / 3;
     }
   else if (name[0] == '#')        /* An old X11 format; convert to newer */