1 |
leio 08/06/04 13:24:37 |
2 |
|
3 |
Added: evolution-2.12.3-CVE-2008-1109.patch |
4 |
evolution-2.22.2-CVE-2008-1108.patch |
5 |
evolution-2.22.2-CVE-2008-1109.patch |
6 |
evolution-2.12.3-CVE-2008-1108.patch |
7 |
Log: |
8 |
Fix iCalendar buffer overflow vulnerabilities, bug #223963 |
9 |
(Portage version: 2.1.5.3, RepoMan options: --force) |
10 |
|
11 |
Revision Changes Path |
12 |
1.1 mail-client/evolution/files/evolution-2.12.3-CVE-2008-1109.patch |
13 |
|
14 |
file : http://sources.gentoo.org/viewcvs.py/gentoo-x86/mail-client/evolution/files/evolution-2.12.3-CVE-2008-1109.patch?rev=1.1&view=markup |
15 |
plain: http://sources.gentoo.org/viewcvs.py/gentoo-x86/mail-client/evolution/files/evolution-2.12.3-CVE-2008-1109.patch?rev=1.1&content-type=text/plain |
16 |
|
17 |
Index: evolution-2.12.3-CVE-2008-1109.patch |
18 |
=================================================================== |
19 |
Index: calendar/gui/itip-utils.c |
20 |
=================================================================== |
21 |
--- calendar/gui/itip-utils.c.orig |
22 |
+++ calendar/gui/itip-utils.c |
23 |
@@ -176,50 +176,16 @@ get_attendee_if_attendee_sentby_is_user |
24 |
} |
25 |
|
26 |
static char * |
27 |
-html_new_lines_for (char *string) |
28 |
+html_new_lines_for (const char *string) |
29 |
{ |
30 |
- char *html_string = (char *) malloc (sizeof (char)* (3500)); |
31 |
- int length = strlen (string); |
32 |
- int index = 0; |
33 |
- char *index_ptr = string; |
34 |
- char *temp = string; |
35 |
+ gchar **lines; |
36 |
+ gchar *joined; |
37 |
|
38 |
- /*Find the first occurence*/ |
39 |
- index_ptr = strstr ((const char *)temp, "\n"); |
40 |
+ lines = g_strsplit_set (string, "\n", -1); |
41 |
+ joined = g_strjoinv ("<br>", lines); |
42 |
+ g_strfreev (lines); |
43 |
|
44 |
- /*Doesn't occur*/ |
45 |
- if (index_ptr == NULL) { |
46 |
- strcpy (html_string, (const char *)string); |
47 |
- html_string[length] = '\0'; |
48 |
- return html_string; |
49 |
- } |
50 |
- |
51 |
- /*Split into chunks inserting <br> for \n */ |
52 |
- do{ |
53 |
- while (temp != index_ptr){ |
54 |
- html_string[index++] = *temp; |
55 |
- temp++; |
56 |
- } |
57 |
- temp++; |
58 |
- |
59 |
- html_string[index++] = '<'; |
60 |
- html_string[index++] = 'b'; |
61 |
- html_string[index++] = 'r'; |
62 |
- html_string[index++] = '>'; |
63 |
- |
64 |
- index_ptr = strstr ((const char *)temp, "\n"); |
65 |
- |
66 |
- } while (index_ptr); |
67 |
- |
68 |
- /*Don't leave out the last chunk*/ |
69 |
- while (*temp != '\0'){ |
70 |
- html_string[index++] = *temp; |
71 |
- temp++; |
72 |
- } |
73 |
- |
74 |
- html_string[index] = '\0'; |
75 |
- |
76 |
- return html_string; |
77 |
+ return joined; |
78 |
} |
79 |
|
80 |
char * |
81 |
|
82 |
|
83 |
|
84 |
1.1 mail-client/evolution/files/evolution-2.22.2-CVE-2008-1108.patch |
85 |
|
86 |
file : http://sources.gentoo.org/viewcvs.py/gentoo-x86/mail-client/evolution/files/evolution-2.22.2-CVE-2008-1108.patch?rev=1.1&view=markup |
87 |
plain: http://sources.gentoo.org/viewcvs.py/gentoo-x86/mail-client/evolution/files/evolution-2.22.2-CVE-2008-1108.patch?rev=1.1&content-type=text/plain |
88 |
|
89 |
Index: evolution-2.22.2-CVE-2008-1108.patch |
90 |
=================================================================== |
91 |
Index: calendar/gui/e-itip-control.c |
92 |
=================================================================== |
93 |
--- calendar/gui/e-itip-control.c (revision 35555) |
94 |
+++ calendar/gui/e-itip-control.c (working copy) |
95 |
@@ -660,7 +660,7 @@ find_attendee (icalcomponent *ical_comp, |
96 |
|
97 |
static void |
98 |
write_label_piece (EItipControl *itip, ECalComponentDateTime *dt, |
99 |
- char *buffer, int size, |
100 |
+ GString *buffer, |
101 |
const char *stext, const char *etext, |
102 |
gboolean just_date) |
103 |
{ |
104 |
@@ -685,13 +685,13 @@ write_label_piece (EItipControl *itip, E |
105 |
tmp_tm.tm_hour = tmp_tm.tm_min = tmp_tm.tm_sec = 0; |
106 |
|
107 |
if (stext != NULL) |
108 |
- strcat (buffer, stext); |
109 |
+ g_string_append (buffer, stext); |
110 |
|
111 |
e_time_format_date_and_time (&tmp_tm, |
112 |
calendar_config_get_24_hour_format (), |
113 |
FALSE, FALSE, |
114 |
time_buf, sizeof (time_buf)); |
115 |
- strcat (buffer, time_buf); |
116 |
+ g_string_append (buffer, time_buf); |
117 |
|
118 |
if (!dt->value->is_utc && dt->tzid) { |
119 |
zone = icalcomponent_get_timezone (priv->top_level, dt->tzid); |
120 |
@@ -703,21 +703,21 @@ write_label_piece (EItipControl *itip, E |
121 |
UTF-8. But it probably is not translated. */ |
122 |
display_name = icaltimezone_get_display_name (zone); |
123 |
if (display_name && *display_name) { |
124 |
- strcat (buffer, " <font size=-1>["); |
125 |
+ g_string_append_len (buffer, " <font size=-1>[", 16); |
126 |
|
127 |
/* We check if it is one of our builtin timezone names, |
128 |
in which case we call gettext to translate it. */ |
129 |
if (icaltimezone_get_builtin_timezone (display_name)) { |
130 |
- strcat (buffer, _(display_name)); |
131 |
+ g_string_append_printf (buffer, "%s", _(display_name)); |
132 |
} else { |
133 |
- strcat (buffer, display_name); |
134 |
+ g_string_append_printf (buffer, "%s", display_name); |
135 |
} |
136 |
- strcat (buffer, "]</font>"); |
137 |
+ g_string_append_len (buffer, "]</font>", 8); |
138 |
} |
139 |
} |
140 |
|
141 |
if (etext != NULL) |
142 |
- strcat (buffer, etext); |
143 |
+ g_string_append (buffer, etext); |
144 |
} |
145 |
|
146 |
static const char * |
147 |
@@ -754,19 +754,17 @@ get_dayname (struct icalrecurrencetype * |
148 |
|
149 |
static void |
150 |
write_recurrence_piece (EItipControl *itip, ECalComponent *comp, |
151 |
- char *buffer, int size) |
152 |
+ GString *buffer) |
153 |
{ |
154 |
GSList *rrules; |
155 |
struct icalrecurrencetype *r; |
156 |
- int len, i; |
157 |
+ int i; |
158 |
|
159 |
- strcpy (buffer, "<b>Recurring:</b> "); |
160 |
- len = strlen (buffer); |
161 |
- buffer += len; |
162 |
- size -= len; |
163 |
+ g_string_append_len (buffer, "<b>Recurring:</b> ", 18); |
164 |
|
165 |
if (!e_cal_component_has_simple_recurrence (comp)) { |
166 |
- strcpy (buffer, _("Yes. (Complex Recurrence)")); |
167 |
+ g_string_append_printf ( |
168 |
+ buffer, "%s", _("Yes. (Complex Recurrence)")); |
169 |
return; |
170 |
} |
171 |
|
172 |
@@ -782,7 +780,10 @@ write_recurrence_piece (EItipControl *it |
173 |
Every %d day/days" */ |
174 |
/* For Translators : 'Every day' is event Recurring every day */ |
175 |
/* For Translators : 'Every %d days' is event Recurring every %d days. %d is a digit */ |
176 |
- sprintf (buffer, ngettext("Every day", "Every %d days", r->interval), r->interval); |
177 |
+ g_string_append_printf ( |
178 |
+ buffer, ngettext ("Every day", |
179 |
+ "Every %d days", r->interval), |
180 |
+ r->interval); |
181 |
break; |
182 |
|
183 |
case ICAL_WEEKLY_RECURRENCE: |
184 |
@@ -792,29 +793,36 @@ write_recurrence_piece (EItipControl *it |
185 |
Every %d week/weeks" */ |
186 |
/* For Translators : 'Every week' is event Recurring every week */ |
187 |
/* For Translators : 'Every %d weeks' is event Recurring every %d weeks. %d is a digit */ |
188 |
- sprintf (buffer, ngettext("Every week", "Every %d weeks", r->interval), r->interval); |
189 |
+ g_string_append_printf ( |
190 |
+ buffer, ngettext ("Every week", |
191 |
+ "Every %d weeks", r->interval), |
192 |
+ r->interval); |
193 |
} else { |
194 |
/* For Translators : 'Every week on' is event Recurring every week on (dayname) and (dayname) and (dayname) */ |
195 |
/* For Translators : 'Every %d weeks on' is event Recurring: every %d weeks on (dayname) and (dayname). %d is a digit */ |
196 |
- sprintf (buffer, ngettext("Every week on ", "Every %d weeks on ", r->interval), r->interval); |
197 |
+ g_string_append_printf ( |
198 |
+ buffer, ngettext ("Every week on ", |
199 |
+ "Every %d weeks on ", r->interval), |
200 |
+ r->interval); |
201 |
|
202 |
for (i = 1; i < 8 && r->by_day[i] != ICAL_RECURRENCE_ARRAY_MAX; i++) { |
203 |
if (i > 1) |
204 |
- strcat (buffer, ", "); |
205 |
- strcat (buffer, get_dayname (r, i - 1)); |
206 |
+ g_string_append_len (buffer, ", ", 2); |
207 |
+ g_string_append (buffer, get_dayname (r, i - 1)); |
208 |
} |
209 |
if (i > 1) |
210 |
/* For Translators : 'and' is part of the sentence 'event recurring every week on (dayname) and (dayname)' */ |
211 |
- strcat (buffer, _(" and ")); |
212 |
- strcat (buffer, get_dayname (r, i - 1)); |
213 |
+ g_string_append_printf (buffer, "%s", _(" and ")); |
214 |
+ g_string_append (buffer, get_dayname (r, i - 1)); |
215 |
} |
216 |
break; |
217 |
|
218 |
case ICAL_MONTHLY_RECURRENCE: |
219 |
if (r->by_month_day[0] != ICAL_RECURRENCE_ARRAY_MAX) { |
220 |
/* For Translators : 'The %s day of' is part of the sentence 'event recurring on the (nth) day of every month.' */ |
221 |
- sprintf (buffer, _("The %s day of "), |
222 |
- nth (r->by_month_day[0])); |
223 |
+ g_string_append_printf ( |
224 |
+ buffer, _("The %s day of "), |
225 |
+ nth (r->by_month_day[0])); |
226 |
} else { |
227 |
int pos; |
228 |
|
229 |
@@ -828,20 +836,21 @@ write_recurrence_piece (EItipControl *it |
230 |
|
231 |
/* For Translators : 'The %s %s of' is part of the sentence 'event recurring on the (nth) (dayname) of every month.' |
232 |
eg,third monday of every month */ |
233 |
- sprintf (buffer, _("The %s %s of "), |
234 |
- nth (pos), get_dayname (r, 0)); |
235 |
+ g_string_append_printf ( |
236 |
+ buffer, _("The %s %s of "), |
237 |
+ nth (pos), get_dayname (r, 0)); |
238 |
} |
239 |
|
240 |
- len = strlen (buffer); |
241 |
- buffer += len; |
242 |
- size -= len; |
243 |
/* For Translators: In this can also be translated as "With the period of %d |
244 |
month/months", where %d is a number. The entire sentence is of the form "Recurring: |
245 |
Every %d month/months" */ |
246 |
/* For Translators : 'every month' is part of the sentence 'event recurring on the (nth) day of every month.' */ |
247 |
/* For Translators : 'every %d months' is part of the sentence 'event recurring on the (nth) day of every %d months.' |
248 |
%d is a digit */ |
249 |
- sprintf (buffer, ngettext("every month","every %d months", r->interval), r->interval); |
250 |
+ g_string_append_printf ( |
251 |
+ buffer, ngettext ("every month", |
252 |
+ "every %d months", r->interval), |
253 |
+ r->interval); |
254 |
break; |
255 |
|
256 |
case ICAL_YEARLY_RECURRENCE: |
257 |
@@ -850,20 +859,22 @@ write_recurrence_piece (EItipControl *it |
258 |
Every %d year/years" */ |
259 |
/* For Translators : 'Every year' is event Recurring every year */ |
260 |
/* For Translators : 'Every %d years' is event Recurring every %d years. %d is a digit */ |
261 |
- sprintf (buffer, ngettext("Every year", "Every %d years", r->interval), r->interval); |
262 |
+ g_string_append_printf ( |
263 |
+ buffer, ngettext ("Every year", |
264 |
+ "Every %d years", r->interval), |
265 |
+ r->interval); |
266 |
break; |
267 |
|
268 |
default: |
269 |
g_return_if_reached (); |
270 |
} |
271 |
|
272 |
- len = strlen (buffer); |
273 |
- buffer += len; |
274 |
- size -= len; |
275 |
if (r->count) { |
276 |
/* For Translators:'a total of %d time' is part of the sentence of the form 'event recurring every day,a total of % time.' %d is a digit*/ |
277 |
/* For Translators:'a total of %d times' is part of the sentence of the form 'event recurring every day,a total of % times.' %d is a digit*/ |
278 |
- sprintf (buffer, ngettext("a total of %d time", " a total of %d times", r->count), r->count); |
279 |
+ g_string_append_printf ( |
280 |
+ buffer, ngettext ("a total of %d time", |
281 |
+ " a total of %d times", r->count), r->count); |
282 |
} else if (!icaltime_is_null_time (r->until)) { |
283 |
ECalComponentDateTime dt; |
284 |
|
285 |
@@ -871,12 +882,12 @@ write_recurrence_piece (EItipControl *it |
286 |
dt.value = &r->until; |
287 |
dt.tzid = icaltimezone_get_tzid ((icaltimezone *)r->until.zone); |
288 |
|
289 |
- write_label_piece (itip, &dt, buffer, size, |
290 |
+ write_label_piece (itip, &dt, buffer, |
291 |
/* For Translators : ', ending on' is part of the sentence of the form 'event recurring every day, ending on (date).'*/ |
292 |
_(", ending on "), NULL, TRUE); |
293 |
} |
294 |
|
295 |
- strcat (buffer, "<br>"); |
296 |
+ g_string_append_len (buffer, "<br>", 4); |
297 |
} |
298 |
|
299 |
static void |
300 |
@@ -884,47 +895,51 @@ set_date_label (EItipControl *itip, GtkH |
301 |
ECalComponent *comp) |
302 |
{ |
303 |
ECalComponentDateTime datetime; |
304 |
- static char buffer[1024]; |
305 |
+ GString *buffer; |
306 |
gchar *str; |
307 |
gboolean wrote = FALSE, task_completed = FALSE; |
308 |
ECalComponentVType type; |
309 |
|
310 |
+ buffer = g_string_sized_new (1024); |
311 |
type = e_cal_component_get_vtype (comp); |
312 |
|
313 |
- buffer[0] = '\0'; |
314 |
e_cal_component_get_dtstart (comp, &datetime); |
315 |
if (datetime.value) { |
316 |
/* For Translators : 'starts' is starts:date implying a task starts on what date */ |
317 |
str = g_strdup_printf ("<b>%s:</b>", _("Starts")); |
318 |
- write_label_piece (itip, &datetime, buffer, 1024, |
319 |
- str, |
320 |
- "<br>", FALSE); |
321 |
- gtk_html_write (html, html_stream, buffer, strlen(buffer)); |
322 |
+ write_label_piece (itip, &datetime, buffer, str, "<br>", FALSE); |
323 |
+ gtk_html_write (html, html_stream, buffer->str, buffer->len); |
324 |
wrote = TRUE; |
325 |
g_free (str); |
326 |
} |
327 |
e_cal_component_free_datetime (&datetime); |
328 |
|
329 |
- buffer[0] = '\0'; |
330 |
+ /* Reset the buffer. */ |
331 |
+ g_string_truncate (buffer, 0); |
332 |
+ |
333 |
e_cal_component_get_dtend (comp, &datetime); |
334 |
if (datetime.value){ |
335 |
/* For Translators : 'ends' is ends:date implying a task ends on what date */ |
336 |
str = g_strdup_printf ("<b>%s:</b>", _("Ends")); |
337 |
- write_label_piece (itip, &datetime, buffer, 1024, str, "<br>", FALSE); |
338 |
- gtk_html_write (html, html_stream, buffer, strlen (buffer)); |
339 |
+ write_label_piece (itip, &datetime, buffer, str, "<br>", FALSE); |
340 |
+ gtk_html_write (html, html_stream, buffer->str, buffer->len); |
341 |
wrote = TRUE; |
342 |
g_free (str); |
343 |
} |
344 |
e_cal_component_free_datetime (&datetime); |
345 |
|
346 |
- buffer[0] = '\0'; |
347 |
+ /* Reset the buffer. */ |
348 |
+ g_string_truncate (buffer, 0); |
349 |
+ |
350 |
if (e_cal_component_has_recurrences (comp)) { |
351 |
- write_recurrence_piece (itip, comp, buffer, 1024); |
352 |
- gtk_html_write (html, html_stream, buffer, strlen (buffer)); |
353 |
+ write_recurrence_piece (itip, comp, buffer); |
354 |
+ gtk_html_write (html, html_stream, buffer->str, buffer->len); |
355 |
wrote = TRUE; |
356 |
} |
357 |
|
358 |
- buffer[0] = '\0'; |
359 |
+ /* Reset the buffer. */ |
360 |
+ g_string_truncate (buffer, 0); |
361 |
+ |
362 |
datetime.tzid = NULL; |
363 |
e_cal_component_get_completed (comp, &datetime.value); |
364 |
if (type == E_CAL_COMPONENT_TODO && datetime.value) { |
365 |
@@ -932,20 +947,22 @@ set_date_label (EItipControl *itip, GtkH |
366 |
timezone. */ |
367 |
str = g_strdup_printf ("<b>%s:</b>", _("Completed")); |
368 |
datetime.value->is_utc = TRUE; |
369 |
- write_label_piece (itip, &datetime, buffer, 1024, str, "<br>", FALSE); |
370 |
- gtk_html_write (html, html_stream, buffer, strlen (buffer)); |
371 |
+ write_label_piece (itip, &datetime, buffer, str, "<br>", FALSE); |
372 |
+ gtk_html_write (html, html_stream, buffer->str, buffer->len); |
373 |
wrote = TRUE; |
374 |
task_completed = TRUE; |
375 |
g_free (str); |
376 |
} |
377 |
e_cal_component_free_datetime (&datetime); |
378 |
|
379 |
- buffer[0] = '\0'; |
380 |
+ /* Reset the buffer. */ |
381 |
+ g_string_truncate (buffer, 0); |
382 |
+ |
383 |
e_cal_component_get_due (comp, &datetime); |
384 |
if (type == E_CAL_COMPONENT_TODO && !task_completed && datetime.value) { |
385 |
str = g_strdup_printf ("<b>%s:</b>", _("Due")); |
386 |
- write_label_piece (itip, &datetime, buffer, 1024, str, "<br>", FALSE); |
387 |
- gtk_html_write (html, html_stream, buffer, strlen (buffer)); |
388 |
+ write_label_piece (itip, &datetime, buffer, str, "<br>", FALSE); |
389 |
+ gtk_html_write (html, html_stream, buffer->str, buffer->len); |
390 |
wrote = TRUE; |
391 |
g_free (str); |
392 |
} |
393 |
@@ -954,6 +971,8 @@ set_date_label (EItipControl *itip, GtkH |
394 |
|
395 |
if (wrote) |
396 |
gtk_html_stream_printf (html_stream, "<br>"); |
397 |
+ |
398 |
+ g_string_free (buffer, TRUE); |
399 |
} |
400 |
|
401 |
static void |
402 |
|
403 |
|
404 |
|
405 |
1.1 mail-client/evolution/files/evolution-2.22.2-CVE-2008-1109.patch |
406 |
|
407 |
file : http://sources.gentoo.org/viewcvs.py/gentoo-x86/mail-client/evolution/files/evolution-2.22.2-CVE-2008-1109.patch?rev=1.1&view=markup |
408 |
plain: http://sources.gentoo.org/viewcvs.py/gentoo-x86/mail-client/evolution/files/evolution-2.22.2-CVE-2008-1109.patch?rev=1.1&content-type=text/plain |
409 |
|
410 |
Index: evolution-2.22.2-CVE-2008-1109.patch |
411 |
=================================================================== |
412 |
Index: calendar/gui/itip-utils.c |
413 |
=================================================================== |
414 |
--- calendar/gui/itip-utils.c (revision 35555) |
415 |
+++ calendar/gui/itip-utils.c (working copy) |
416 |
@@ -172,50 +172,16 @@ get_attendee_if_attendee_sentby_is_user |
417 |
} |
418 |
|
419 |
static char * |
420 |
-html_new_lines_for (char *string) |
421 |
+html_new_lines_for (const char *string) |
422 |
{ |
423 |
- char *html_string = (char *) malloc (sizeof (char)* (3500)); |
424 |
- int length = strlen (string); |
425 |
- int index = 0; |
426 |
- char *index_ptr = string; |
427 |
- char *temp = string; |
428 |
+ gchar **lines; |
429 |
+ gchar *joined; |
430 |
|
431 |
- /*Find the first occurence*/ |
432 |
- index_ptr = strstr ((const char *)temp, "\n"); |
433 |
+ lines = g_strsplit_set (string, "\n", -1); |
434 |
+ joined = g_strjoinv ("<br>", lines); |
435 |
+ g_strfreev (lines); |
436 |
|
437 |
- /*Doesn't occur*/ |
438 |
- if (index_ptr == NULL) { |
439 |
- strcpy (html_string, (const char *)string); |
440 |
- html_string[length] = '\0'; |
441 |
- return html_string; |
442 |
- } |
443 |
- |
444 |
- /*Split into chunks inserting <br> for \n */ |
445 |
- do{ |
446 |
- while (temp != index_ptr){ |
447 |
- html_string[index++] = *temp; |
448 |
- temp++; |
449 |
- } |
450 |
- temp++; |
451 |
- |
452 |
- html_string[index++] = '<'; |
453 |
- html_string[index++] = 'b'; |
454 |
- html_string[index++] = 'r'; |
455 |
- html_string[index++] = '>'; |
456 |
- |
457 |
- index_ptr = strstr ((const char *)temp, "\n"); |
458 |
- |
459 |
- } while (index_ptr); |
460 |
- |
461 |
- /*Don't leave out the last chunk*/ |
462 |
- while (*temp != '\0'){ |
463 |
- html_string[index++] = *temp; |
464 |
- temp++; |
465 |
- } |
466 |
- |
467 |
- html_string[index] = '\0'; |
468 |
- |
469 |
- return html_string; |
470 |
+ return joined; |
471 |
} |
472 |
|
473 |
char * |
474 |
|
475 |
|
476 |
|
477 |
1.1 mail-client/evolution/files/evolution-2.12.3-CVE-2008-1108.patch |
478 |
|
479 |
file : http://sources.gentoo.org/viewcvs.py/gentoo-x86/mail-client/evolution/files/evolution-2.12.3-CVE-2008-1108.patch?rev=1.1&view=markup |
480 |
plain: http://sources.gentoo.org/viewcvs.py/gentoo-x86/mail-client/evolution/files/evolution-2.12.3-CVE-2008-1108.patch?rev=1.1&content-type=text/plain |
481 |
|
482 |
Index: evolution-2.12.3-CVE-2008-1108.patch |
483 |
=================================================================== |
484 |
Index: calendar/gui/e-itip-control.c |
485 |
=================================================================== |
486 |
--- calendar/gui/e-itip-control.c.orig |
487 |
+++ calendar/gui/e-itip-control.c |
488 |
@@ -650,7 +650,7 @@ find_attendee (icalcomponent *ical_comp, |
489 |
|
490 |
static void |
491 |
write_label_piece (EItipControl *itip, ECalComponentDateTime *dt, |
492 |
- char *buffer, int size, |
493 |
+ GString *buffer, |
494 |
const char *stext, const char *etext, |
495 |
gboolean just_date) |
496 |
{ |
497 |
@@ -675,13 +675,13 @@ write_label_piece (EItipControl *itip, E |
498 |
tmp_tm.tm_hour = tmp_tm.tm_min = tmp_tm.tm_sec = 0; |
499 |
|
500 |
if (stext != NULL) |
501 |
- strcat (buffer, stext); |
502 |
+ g_string_append (buffer, stext); |
503 |
|
504 |
e_time_format_date_and_time (&tmp_tm, |
505 |
calendar_config_get_24_hour_format (), |
506 |
FALSE, FALSE, |
507 |
time_buf, sizeof (time_buf)); |
508 |
- strcat (buffer, time_buf); |
509 |
+ g_string_append (buffer, time_buf); |
510 |
|
511 |
if (!dt->value->is_utc && dt->tzid) { |
512 |
zone = icalcomponent_get_timezone (priv->top_level, dt->tzid); |
513 |
@@ -693,21 +693,21 @@ write_label_piece (EItipControl *itip, E |
514 |
UTF-8. But it probably is not translated. */ |
515 |
display_name = icaltimezone_get_display_name (zone); |
516 |
if (display_name && *display_name) { |
517 |
- strcat (buffer, " <font size=-1>["); |
518 |
+ g_string_append_len (buffer, " <font size=-1>[", 16); |
519 |
|
520 |
/* We check if it is one of our builtin timezone names, |
521 |
in which case we call gettext to translate it. */ |
522 |
if (icaltimezone_get_builtin_timezone (display_name)) { |
523 |
- strcat (buffer, _(display_name)); |
524 |
+ g_string_append_printf (buffer, "%s", _(display_name)); |
525 |
} else { |
526 |
- strcat (buffer, display_name); |
527 |
+ g_string_append_printf (buffer, "%s", display_name); |
528 |
} |
529 |
- strcat (buffer, "]</font>"); |
530 |
+ g_string_append_len (buffer, "]</font>", 8); |
531 |
} |
532 |
} |
533 |
|
534 |
if (etext != NULL) |
535 |
- strcat (buffer, etext); |
536 |
+ g_string_append (buffer, etext); |
537 |
} |
538 |
|
539 |
static const char * |
540 |
@@ -744,19 +744,17 @@ get_dayname (struct icalrecurrencetype * |
541 |
|
542 |
static void |
543 |
write_recurrence_piece (EItipControl *itip, ECalComponent *comp, |
544 |
- char *buffer, int size) |
545 |
+ GString *buffer) |
546 |
{ |
547 |
GSList *rrules; |
548 |
struct icalrecurrencetype *r; |
549 |
- int len, i; |
550 |
+ int i; |
551 |
|
552 |
- strcpy (buffer, "<b>Recurring:</b> "); |
553 |
- len = strlen (buffer); |
554 |
- buffer += len; |
555 |
- size -= len; |
556 |
+ g_string_append_len (buffer, "<b>Recurring:</b> ", 18); |
557 |
|
558 |
if (!e_cal_component_has_simple_recurrence (comp)) { |
559 |
- strcpy (buffer, _("Yes. (Complex Recurrence)")); |
560 |
+ g_string_append_printf ( |
561 |
+ buffer, "%s", _("Yes. (Complex Recurrence)")); |
562 |
return; |
563 |
} |
564 |
|
565 |
@@ -772,7 +770,10 @@ write_recurrence_piece (EItipControl *it |
566 |
Every %d day/days" */ |
567 |
/* For Translators : 'Every day' is event Recurring every day */ |
568 |
/* For Translators : 'Every %d days' is event Recurring every %d days. %d is a digit */ |
569 |
- sprintf (buffer, ngettext("Every day", "Every %d days", r->interval), r->interval); |
570 |
+ g_string_append_printf ( |
571 |
+ buffer, ngettext ("Every day", |
572 |
+ "Every %d days", r->interval), |
573 |
+ r->interval); |
574 |
break; |
575 |
|
576 |
case ICAL_WEEKLY_RECURRENCE: |
577 |
@@ -782,29 +783,36 @@ write_recurrence_piece (EItipControl *it |
578 |
Every %d week/weeks" */ |
579 |
/* For Translators : 'Every week' is event Recurring every week */ |
580 |
/* For Translators : 'Every %d weeks' is event Recurring every %d weeks. %d is a digit */ |
581 |
- sprintf (buffer, ngettext("Every week", "Every %d weeks", r->interval), r->interval); |
582 |
+ g_string_append_printf ( |
583 |
+ buffer, ngettext ("Every week", |
584 |
+ "Every %d weeks", r->interval), |
585 |
+ r->interval); |
586 |
} else { |
587 |
/* For Translators : 'Every week on' is event Recurring every week on (dayname) and (dayname) and (dayname) */ |
588 |
/* For Translators : 'Every %d weeks on' is event Recurring: every %d weeks on (dayname) and (dayname). %d is a digit */ |
589 |
- sprintf (buffer, ngettext("Every week on ", "Every %d weeks on ", r->interval), r->interval); |
590 |
+ g_string_append_printf ( |
591 |
+ buffer, ngettext ("Every week on ", |
592 |
+ "Every %d weeks on ", r->interval), |
593 |
+ r->interval); |
594 |
|
595 |
for (i = 1; i < 8 && r->by_day[i] != ICAL_RECURRENCE_ARRAY_MAX; i++) { |
596 |
if (i > 1) |
597 |
- strcat (buffer, ", "); |
598 |
- strcat (buffer, get_dayname (r, i - 1)); |
599 |
+ g_string_append_len (buffer, ", ", 2); |
600 |
+ g_string_append (buffer, get_dayname (r, i - 1)); |
601 |
} |
602 |
if (i > 1) |
603 |
/* For Translators : 'and' is part of the sentence 'event recurring every week on (dayname) and (dayname)' */ |
604 |
- strcat (buffer, _(" and ")); |
605 |
- strcat (buffer, get_dayname (r, i - 1)); |
606 |
+ g_string_append_printf (buffer, "%s", _(" and ")); |
607 |
+ g_string_append (buffer, get_dayname (r, i - 1)); |
608 |
} |
609 |
break; |
610 |
|
611 |
case ICAL_MONTHLY_RECURRENCE: |
612 |
if (r->by_month_day[0] != ICAL_RECURRENCE_ARRAY_MAX) { |
613 |
/* For Translators : 'The %s day of' is part of the sentence 'event recurring on the (nth) day of every month.' */ |
614 |
- sprintf (buffer, _("The %s day of "), |
615 |
- nth (r->by_month_day[0])); |
616 |
+ g_string_append_printf ( |
617 |
+ buffer, _("The %s day of "), |
618 |
+ nth (r->by_month_day[0])); |
619 |
} else { |
620 |
int pos; |
621 |
|
622 |
@@ -818,20 +826,21 @@ write_recurrence_piece (EItipControl *it |
623 |
|
624 |
/* For Translators : 'The %s %s of' is part of the sentence 'event recurring on the (nth) (dayname) of every month.' |
625 |
eg,third monday of every month */ |
626 |
- sprintf (buffer, _("The %s %s of "), |
627 |
- nth (pos), get_dayname (r, 0)); |
628 |
+ g_string_append_printf ( |
629 |
+ buffer, _("The %s %s of "), |
630 |
+ nth (pos), get_dayname (r, 0)); |
631 |
} |
632 |
|
633 |
- len = strlen (buffer); |
634 |
- buffer += len; |
635 |
- size -= len; |
636 |
/* For Translators: In this can also be translated as "With the period of %d |
637 |
month/months", where %d is a number. The entire sentence is of the form "Recurring: |
638 |
Every %d month/months" */ |
639 |
/* For Translators : 'every month' is part of the sentence 'event recurring on the (nth) day of every month.' */ |
640 |
/* For Translators : 'every %d months' is part of the sentence 'event recurring on the (nth) day of every %d months.' |
641 |
%d is a digit */ |
642 |
- sprintf (buffer, ngettext("every month","every %d months", r->interval), r->interval); |
643 |
+ g_string_append_printf ( |
644 |
+ buffer, ngettext ("every month", |
645 |
+ "every %d months", r->interval), |
646 |
+ r->interval); |
647 |
break; |
648 |
|
649 |
case ICAL_YEARLY_RECURRENCE: |
650 |
@@ -840,20 +849,22 @@ write_recurrence_piece (EItipControl *it |
651 |
Every %d year/years" */ |
652 |
/* For Translators : 'Every year' is event Recurring every year */ |
653 |
/* For Translators : 'Every %d years' is event Recurring every %d years. %d is a digit */ |
654 |
- sprintf (buffer, ngettext("Every year", "Every %d years", r->interval), r->interval); |
655 |
+ g_string_append_printf ( |
656 |
+ buffer, ngettext ("Every year", |
657 |
+ "Every %d years", r->interval), |
658 |
+ r->interval); |
659 |
break; |
660 |
|
661 |
default: |
662 |
g_return_if_reached (); |
663 |
} |
664 |
|
665 |
- len = strlen (buffer); |
666 |
- buffer += len; |
667 |
- size -= len; |
668 |
if (r->count) { |
669 |
/* For Translators:'a total of %d time' is part of the sentence of the form 'event recurring every day,a total of % time.' %d is a digit*/ |
670 |
/* For Translators:'a total of %d times' is part of the sentence of the form 'event recurring every day,a total of % times.' %d is a digit*/ |
671 |
- sprintf (buffer, ngettext("a total of %d time", " a total of %d times", r->count), r->count); |
672 |
+ g_string_append_printf ( |
673 |
+ buffer, ngettext ("a total of %d time", |
674 |
+ " a total of %d times", r->count), r->count); |
675 |
} else if (!icaltime_is_null_time (r->until)) { |
676 |
ECalComponentDateTime dt; |
677 |
|
678 |
@@ -861,12 +872,12 @@ write_recurrence_piece (EItipControl *it |
679 |
dt.value = &r->until; |
680 |
dt.tzid = icaltimezone_get_tzid ((icaltimezone *)r->until.zone); |
681 |
|
682 |
- write_label_piece (itip, &dt, buffer, size, |
683 |
+ write_label_piece (itip, &dt, buffer, |
684 |
/* For Translators : ', ending on' is part of the sentence of the form 'event recurring every day, ending on (date).'*/ |
685 |
_(", ending on "), NULL, TRUE); |
686 |
} |
687 |
|
688 |
- strcat (buffer, "<br>"); |
689 |
+ g_string_append_len (buffer, "<br>", 4); |
690 |
} |
691 |
|
692 |
static void |
693 |
@@ -874,47 +885,51 @@ set_date_label (EItipControl *itip, GtkH |
694 |
ECalComponent *comp) |
695 |
{ |
696 |
ECalComponentDateTime datetime; |
697 |
- static char buffer[1024]; |
698 |
+ GString *buffer; |
699 |
gchar *str; |
700 |
gboolean wrote = FALSE, task_completed = FALSE; |
701 |
ECalComponentVType type; |
702 |
|
703 |
+ buffer = g_string_sized_new (1024); |
704 |
type = e_cal_component_get_vtype (comp); |
705 |
|
706 |
- buffer[0] = '\0'; |
707 |
e_cal_component_get_dtstart (comp, &datetime); |
708 |
if (datetime.value) { |
709 |
/* For Translators : 'starts' is starts:date implying a task starts on what date */ |
710 |
str = g_strdup_printf ("<b>%s:</b>", _("Starts")); |
711 |
- write_label_piece (itip, &datetime, buffer, 1024, |
712 |
- str, |
713 |
- "<br>", FALSE); |
714 |
- gtk_html_write (html, html_stream, buffer, strlen(buffer)); |
715 |
+ write_label_piece (itip, &datetime, buffer, str, "<br>", FALSE); |
716 |
+ gtk_html_write (html, html_stream, buffer->str, buffer->len); |
717 |
wrote = TRUE; |
718 |
g_free (str); |
719 |
} |
720 |
e_cal_component_free_datetime (&datetime); |
721 |
|
722 |
- buffer[0] = '\0'; |
723 |
+ /* Reset the buffer. */ |
724 |
+ g_string_truncate (buffer, 0); |
725 |
+ |
726 |
e_cal_component_get_dtend (comp, &datetime); |
727 |
if (datetime.value){ |
728 |
/* For Translators : 'ends' is ends:date implying a task ends on what date */ |
729 |
str = g_strdup_printf ("<b>%s:</b>", _("Ends")); |
730 |
- write_label_piece (itip, &datetime, buffer, 1024, str, "<br>", FALSE); |
731 |
- gtk_html_write (html, html_stream, buffer, strlen (buffer)); |
732 |
+ write_label_piece (itip, &datetime, buffer, str, "<br>", FALSE); |
733 |
+ gtk_html_write (html, html_stream, buffer->str, buffer->len); |
734 |
wrote = TRUE; |
735 |
g_free (str); |
736 |
} |
737 |
e_cal_component_free_datetime (&datetime); |
738 |
|
739 |
- buffer[0] = '\0'; |
740 |
+ /* Reset the buffer. */ |
741 |
+ g_string_truncate (buffer, 0); |
742 |
+ |
743 |
if (e_cal_component_has_recurrences (comp)) { |
744 |
- write_recurrence_piece (itip, comp, buffer, 1024); |
745 |
- gtk_html_write (html, html_stream, buffer, strlen (buffer)); |
746 |
+ write_recurrence_piece (itip, comp, buffer); |
747 |
+ gtk_html_write (html, html_stream, buffer->str, buffer->len); |
748 |
wrote = TRUE; |
749 |
} |
750 |
|
751 |
- buffer[0] = '\0'; |
752 |
+ /* Reset the buffer. */ |
753 |
+ g_string_truncate (buffer, 0); |
754 |
+ |
755 |
datetime.tzid = NULL; |
756 |
e_cal_component_get_completed (comp, &datetime.value); |
757 |
if (type == E_CAL_COMPONENT_TODO && datetime.value) { |
758 |
@@ -922,20 +937,22 @@ set_date_label (EItipControl *itip, GtkH |
759 |
timezone. */ |
760 |
str = g_strdup_printf ("<b>%s:</b>", _("Completed")); |
761 |
datetime.value->is_utc = TRUE; |
762 |
- write_label_piece (itip, &datetime, buffer, 1024, str, "<br>", FALSE); |
763 |
- gtk_html_write (html, html_stream, buffer, strlen (buffer)); |
764 |
+ write_label_piece (itip, &datetime, buffer, str, "<br>", FALSE); |
765 |
+ gtk_html_write (html, html_stream, buffer->str, buffer->len); |
766 |
wrote = TRUE; |
767 |
task_completed = TRUE; |
768 |
g_free (str); |
769 |
} |
770 |
e_cal_component_free_datetime (&datetime); |
771 |
|
772 |
- buffer[0] = '\0'; |
773 |
+ /* Reset the buffer. */ |
774 |
+ g_string_truncate (buffer, 0); |
775 |
+ |
776 |
e_cal_component_get_due (comp, &datetime); |
777 |
if (type == E_CAL_COMPONENT_TODO && !task_completed && datetime.value) { |
778 |
str = g_strdup_printf ("<b>%s:</b>", _("Due")); |
779 |
- write_label_piece (itip, &datetime, buffer, 1024, str, "<br>", FALSE); |
780 |
- gtk_html_write (html, html_stream, buffer, strlen (buffer)); |
781 |
+ write_label_piece (itip, &datetime, buffer, str, "<br>", FALSE); |
782 |
+ gtk_html_write (html, html_stream, buffer->str, buffer->len); |
783 |
wrote = TRUE; |
784 |
g_free (str); |
785 |
} |
786 |
@@ -944,6 +961,8 @@ set_date_label (EItipControl *itip, GtkH |
787 |
|
788 |
if (wrote) |
789 |
gtk_html_stream_printf (html_stream, "<br>"); |
790 |
+ |
791 |
+ g_string_free (buffer, TRUE); |
792 |
} |
793 |
|
794 |
static void |
795 |
|
796 |
|
797 |
|
798 |
-- |
799 |
gentoo-commits@l.g.o mailing list |