aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJan D2010-08-15 10:13:02 +0200
committerJan D2010-08-15 10:13:02 +0200
commitc25ce9d017f6f82ae27256039d313601735dd998 (patch)
tree1188e7d1b793b22b752fa410cfe5b98a78bb8cdf /src
parentc68263b1fd5dc4e5818394ec77368bf11ca2767e (diff)
downloademacs-c25ce9d017f6f82ae27256039d313601735dd998.tar.gz
emacs-c25ce9d017f6f82ae27256039d313601735dd998.zip
Potential buffer overrun and uninit variable fixed, bug 6855.
* keyboard.c (parse_tool_bar_item): malloc buf. Set TOOL_BAR_ITEM_LABEL to empty string if not set to new_lbl (Bug#6855).
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog5
-rw-r--r--src/keyboard.c7
2 files changed, 10 insertions, 2 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 7c76e905c42..316487359cb 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,8 @@
12010-08-15 Jan Djärv <jan.h.d@swipnet.se>
2
3 * keyboard.c (parse_tool_bar_item): malloc buf. Set TOOL_BAR_ITEM_LABEL
4 to empty string if not set to new_lbl (Bug#6855).
5
12010-08-14 Eli Zaretskii <eliz@gnu.org> 62010-08-14 Eli Zaretskii <eliz@gnu.org>
2 7
3 * xterm.c (x_draw_stretch_glyph_string): 8 * xterm.c (x_draw_stretch_glyph_string):
diff --git a/src/keyboard.c b/src/keyboard.c
index c92d359f66a..8691788f418 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -8328,14 +8328,14 @@ parse_tool_bar_item (Lisp_Object key, Lisp_Object item)
8328 Lisp_Object capt = PROP (TOOL_BAR_ITEM_CAPTION); 8328 Lisp_Object capt = PROP (TOOL_BAR_ITEM_CAPTION);
8329 const char *label = SYMBOLP (key) ? (char *) SDATA (SYMBOL_NAME (key)) : ""; 8329 const char *label = SYMBOLP (key) ? (char *) SDATA (SYMBOL_NAME (key)) : "";
8330 const char *caption = STRINGP (capt) ? (char *) SDATA (capt) : ""; 8330 const char *caption = STRINGP (capt) ? (char *) SDATA (capt) : "";
8331 char buf[64];
8332 EMACS_INT max_lbl = 2*tool_bar_max_label_size; 8331 EMACS_INT max_lbl = 2*tool_bar_max_label_size;
8332 char *buf = (char *) xmalloc (max_lbl+1);
8333 Lisp_Object new_lbl; 8333 Lisp_Object new_lbl;
8334 8334
8335 if (strlen (caption) < max_lbl && caption[0] != '\0') 8335 if (strlen (caption) < max_lbl && caption[0] != '\0')
8336 { 8336 {
8337 strcpy (buf, caption); 8337 strcpy (buf, caption);
8338 while (buf[0] != '\0' && buf[strlen (buf) -1] == '.') 8338 while (buf[0] != '\0' && buf[strlen (buf) -1] == '.')
8339 buf[strlen (buf)-1] = '\0'; 8339 buf[strlen (buf)-1] = '\0';
8340 if (strlen (buf) <= max_lbl) 8340 if (strlen (buf) <= max_lbl)
8341 caption = buf; 8341 caption = buf;
@@ -8361,6 +8361,9 @@ parse_tool_bar_item (Lisp_Object key, Lisp_Object item)
8361 new_lbl = Fupcase_initials (make_string (label, strlen (label))); 8361 new_lbl = Fupcase_initials (make_string (label, strlen (label)));
8362 if (SCHARS (new_lbl) <= tool_bar_max_label_size) 8362 if (SCHARS (new_lbl) <= tool_bar_max_label_size)
8363 PROP (TOOL_BAR_ITEM_LABEL) = new_lbl; 8363 PROP (TOOL_BAR_ITEM_LABEL) = new_lbl;
8364 else
8365 PROP (TOOL_BAR_ITEM_LABEL) = make_string ("", 0);
8366 free (buf);
8364 } 8367 }
8365 8368
8366 /* If got a filter apply it on binding. */ 8369 /* If got a filter apply it on binding. */