diff options
author | Jim Meyering <jim@meyering.net> | 2009-06-09 05:57:35 +0000 |
---|---|---|
committer | Jim Meyering <jim@meyering.net> | 2009-06-09 05:57:35 +0000 |
commit | 40aa3f13c674e5c78bb6c0e85de8f5f0ef3690a7 (patch) | |
tree | 3f85141cdf4468a10dfa6323124530907a37f41d | |
parent | 8c9d5f9f86b177497bcff5b41ebb51bf3cd9eadc (diff) | |
download | emacs-40aa3f13c674e5c78bb6c0e85de8f5f0ef3690a7.tar.gz |
x-load-color-file: avoid array bounds error
x-load-color-file expects each line of input to be of the form
"R G B name". But if "name" is missing, it would read name[-1],
and if that value is '\n', zero it.
* xfaces.c (Fx_load_color_file): Handle missing color name.
-rw-r--r-- | src/ChangeLog | 8 | ||||
-rw-r--r-- | src/xfaces.c | 2 |
2 files changed, 9 insertions, 1 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index 399faf60b47..5287bf704c9 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,11 @@ +2009-06-09 Jim Meyering <meyering@redhat.com> + + x-load-color-file: avoid array bounds error + x-load-color-file expects each line of input to be of the form + "R G B name". But if "name" is missing, it would read name[-1], + and if that value is '\n', zero it. + * xfaces.c (Fx_load_color_file): Handle missing color name. + 2009-06-09 Kenichi Handa <handa@m17n.org> * charset.c (Fmap_charset_chars): In docstring, state clearly that diff --git a/src/xfaces.c b/src/xfaces.c index 444376838b9..704d7a92049 100644 --- a/src/xfaces.c +++ b/src/xfaces.c @@ -6630,7 +6630,7 @@ where R,G,B are numbers between 0 and 255 and name is an arbitrary string. */) { char *name = buf + num; num = strlen (name) - 1; - if (name[num] == '\n') + if (num >= 0 && name[num] == '\n') name[num] = 0; cmap = Fcons (Fcons (build_string (name), #ifdef WINDOWSNT |