Merging upstream version 0.5.6.
[debian/lxpanel.git] / debian / patches / panel_draw_label_text.patch
CommitLineData
7ae3952f
DB
1commit cd93c810d7c7ac2bafa53950e012f80ddaacf80a
2Author: Marty Jack <martyj@linux.local>
3Date: Sun May 9 18:12:37 2010 -0400
4
5 Buffer overflow in panel_draw_label_text (Bug2998726)
6
7diff --git a/src/panel.c b/src/panel.c
8index 6ae6baa..d383d61 100644
9--- a/src/panel.c
10+++ b/src/panel.c
11@@ -1054,8 +1054,6 @@ void panel_adjust_geometry_terminology(Panel * p)
12 /* Draw text into a label, with the user preference color and optionally bold. */
13 void panel_draw_label_text(Panel * p, GtkWidget * label, char * text, gboolean bold, gboolean custom_color)
14 {
15- char buffer[512];
16-
17 if (text == NULL)
18 {
19 /* Null string. */
20@@ -1068,7 +1066,7 @@ void panel_draw_label_text(Panel * p, GtkWidget * label, char * text, gboolean b
21 int font_desc;
22 if (p->icon_size < 20)
23 font_desc = 9;
24- else if (p->icon_size >= 20 && p->icon_size < 26)
25+ else if (p->icon_size >= 20 && p->icon_size < 36)
26 font_desc = 10;
27 else
28 font_desc = 12;
29@@ -1091,23 +1089,25 @@ void panel_draw_label_text(Panel * p, GtkWidget * label, char * text, gboolean b
30 if ((custom_color) && (p->usefontcolor))
31 {
32 /* Color, optionally bold. */
33- g_snprintf(buffer, sizeof(buffer), "<span font_desc=\"%d\" color=\"#%06x\">%s%s%s</span>",
34+ gchar * text = g_strdup_printf("<span font_desc=\"%d\" color=\"#%06x\">%s%s%s</span>",
35 font_desc,
36 gcolor2rgb24(&p->gfontcolor),
37 ((bold) ? "<b>" : ""),
38 valid_markup,
39 ((bold) ? "</b>" : ""));
40- gtk_label_set_markup(GTK_LABEL(label), buffer);
41+ gtk_label_set_markup(GTK_LABEL(label), text);
42+ g_free(text);
43 }
44 else
45 {
46 /* No color, optionally bold. */
47- g_snprintf(buffer, sizeof(buffer), "<span font_desc=\"%d\">%s%s%s</span>",
48+ gchar * text = g_strdup_printf("<span font_desc=\"%d\">%s%s%s</span>",
49 font_desc,
50 ((bold) ? "<b>" : ""),
51 valid_markup,
52 ((bold) ? "</b>" : ""));
53- gtk_label_set_markup(GTK_LABEL(label), buffer);
54+ gtk_label_set_markup(GTK_LABEL(label), text);
55+ g_free(text);
56 }
57 g_free(escaped_text);
58 }