View | Details | Raw Unified | Return to bug 72801
Collapse All | Expand All

(-)sylpheed-claws-0.9.12.orig/src/codeconv.c (-6 / +8 lines)
Lines 1450-1456 Link Here
1450
	return cur_locale;
1450
	return cur_locale;
1451
}
1451
}
1452
1452
1453
void conv_unmime_header_overwrite(gchar *str)
1453
void conv_unmime_header_overwrite(gchar *str, size_t strsize)
1454
{
1454
{
1455
	gchar *buf;
1455
	gchar *buf;
1456
	gint buflen;
1456
	gint buflen;
Lines 1464-1475 Link Here
1464
		buflen = strlen(str) * 2 + 1;
1464
		buflen = strlen(str) * 2 + 1;
1465
		Xalloca(buf, buflen, return);
1465
		Xalloca(buf, buflen, return);
1466
		conv_anytodisp(buf, buflen, str);
1466
		conv_anytodisp(buf, buflen, str);
1467
		unmime_header(str, buf);
1467
		unmime_header(str, buf, strsize);
1468
	} else {
1468
	} else {
1469
		buflen = strlen(str) + 1;
1469
		buflen = strlen(str) + 1;
1470
		Xalloca(buf, buflen, return);
1470
		Xalloca(buf, buflen, return);
1471
		unmime_header(buf, str);
1471
		unmime_header(buf, str, buflen);
1472
		strncpy2(str, buf, buflen);
1472
		strncpy2(str, buf, strsize);
1473
	}
1473
	}
1474
}
1474
}
1475
1475
Lines 1478-1483 Link Here
1478
{
1478
{
1479
	CharSet cur_charset;
1479
	CharSet cur_charset;
1480
1480
1481
	g_return_if_fail(str != NULL);
1482
1481
	cur_charset = conv_get_current_charset();
1483
	cur_charset = conv_get_current_charset();
1482
1484
1483
	if (cur_charset == C_EUC_JP) {
1485
	if (cur_charset == C_EUC_JP) {
Lines 1487-1495 Link Here
1487
		buflen = strlen(str) * 2 + 1;
1489
		buflen = strlen(str) * 2 + 1;
1488
		Xalloca(buf, buflen, return);
1490
		Xalloca(buf, buflen, return);
1489
		conv_anytodisp(buf, buflen, str);
1491
		conv_anytodisp(buf, buflen, str);
1490
		unmime_header(outbuf, buf);
1492
		unmime_header(outbuf, buf, outlen);
1491
	} else
1493
	} else
1492
		unmime_header(outbuf, str);
1494
		unmime_header(outbuf, str, outlen);
1493
}
1495
}
1494
1496
1495
#define MAX_LINELEN		76
1497
#define MAX_LINELEN		76
(-)sylpheed-claws-0.9.12.orig/src/codeconv.h (-1 / +1 lines)
Lines 216-222 Link Here
216
216
217
const gchar *conv_get_current_locale		(void);
217
const gchar *conv_get_current_locale		(void);
218
218
219
void conv_unmime_header_overwrite	(gchar		*str);
219
void conv_unmime_header_overwrite	(gchar		*str, size_t strsize);
220
void conv_unmime_header			(gchar		*outbuf,
220
void conv_unmime_header			(gchar		*outbuf,
221
					 gint		 outlen,
221
					 gint		 outlen,
222
					 const gchar	*str,
222
					 const gchar	*str,
(-)sylpheed-claws-0.9.12.orig/src/compose.c (-5 / +5 lines)
Lines 1595-1606 Link Here
1595
	fclose(fp);
1595
	fclose(fp);
1596
1596
1597
	if (hentry[H_REPLY_TO].body != NULL) {
1597
	if (hentry[H_REPLY_TO].body != NULL) {
1598
		conv_unmime_header_overwrite(hentry[H_REPLY_TO].body);
1598
		conv_unmime_header_overwrite(hentry[H_REPLY_TO].body, strlen(hentry[H_REPLY_TO].body));
1599
		compose->replyto = hentry[H_REPLY_TO].body;
1599
		compose->replyto = hentry[H_REPLY_TO].body;
1600
		hentry[H_REPLY_TO].body = NULL;
1600
		hentry[H_REPLY_TO].body = NULL;
1601
	}
1601
	}
1602
	if (hentry[H_CC].body != NULL) {
1602
	if (hentry[H_CC].body != NULL) {
1603
		conv_unmime_header_overwrite(hentry[H_CC].body);
1603
		conv_unmime_header_overwrite(hentry[H_CC].body, strlen(hentry[H_CC].body));
1604
		compose->cc = hentry[H_CC].body;
1604
		compose->cc = hentry[H_CC].body;
1605
		hentry[H_CC].body = NULL;
1605
		hentry[H_CC].body = NULL;
1606
	}
1606
	}
Lines 1616-1634 Link Here
1616
	}
1616
	}
1617
	if (hentry[H_BCC].body != NULL) {
1617
	if (hentry[H_BCC].body != NULL) {
1618
		if (compose->mode == COMPOSE_REEDIT) {
1618
		if (compose->mode == COMPOSE_REEDIT) {
1619
			conv_unmime_header_overwrite(hentry[H_BCC].body);
1619
			conv_unmime_header_overwrite(hentry[H_BCC].body, strlen(hentry[H_BCC].body));
1620
			compose->bcc = hentry[H_BCC].body;
1620
			compose->bcc = hentry[H_BCC].body;
1621
		} else
1621
		} else
1622
			g_free(hentry[H_BCC].body);
1622
			g_free(hentry[H_BCC].body);
1623
		hentry[H_BCC].body = NULL;
1623
		hentry[H_BCC].body = NULL;
1624
	}
1624
	}
1625
	if (hentry[H_NEWSGROUPS].body != NULL) {
1625
	if (hentry[H_NEWSGROUPS].body != NULL) {
1626
		conv_unmime_header_overwrite(hentry[H_NEWSGROUPS].body);
1626
		conv_unmime_header_overwrite(hentry[H_NEWSGROUPS].body, strlen(hentry[H_NEWSGROUPS].body));
1627
		compose->newsgroups = hentry[H_NEWSGROUPS].body;
1627
		compose->newsgroups = hentry[H_NEWSGROUPS].body;
1628
		hentry[H_NEWSGROUPS].body = NULL;
1628
		hentry[H_NEWSGROUPS].body = NULL;
1629
	}
1629
	}
1630
	if (hentry[H_FOLLOWUP_TO].body != NULL) {
1630
	if (hentry[H_FOLLOWUP_TO].body != NULL) {
1631
		conv_unmime_header_overwrite(hentry[H_FOLLOWUP_TO].body);
1631
		conv_unmime_header_overwrite(hentry[H_FOLLOWUP_TO].body, strlen(hentry[H_FOLLOWUP_TO].body));
1632
		compose->followup_to = hentry[H_FOLLOWUP_TO].body;
1632
		compose->followup_to = hentry[H_FOLLOWUP_TO].body;
1633
		hentry[H_FOLLOWUP_TO].body = NULL;
1633
		hentry[H_FOLLOWUP_TO].body = NULL;
1634
	}
1634
	}
(-)sylpheed-claws-0.9.12.orig/src/procmime.c (-6 / +6 lines)
Lines 996-1006 Link Here
996
	fseek(fp, mimeinfo->offset, SEEK_SET);
996
	fseek(fp, mimeinfo->offset, SEEK_SET);
997
	procheader_get_header_fields(fp, hentry);
997
	procheader_get_header_fields(fp, hentry);
998
	if (hentry[0].body != NULL)
998
	if (hentry[0].body != NULL)
999
		conv_unmime_header_overwrite(hentry[0].body);
999
		conv_unmime_header_overwrite(hentry[0].body, strlen(hentry[0].body));
1000
	if (hentry[2].body != NULL)
1000
	if (hentry[2].body != NULL)
1001
		conv_unmime_header_overwrite(hentry[2].body);
1001
		conv_unmime_header_overwrite(hentry[2].body, strlen(hentry[2].body));
1002
	if (hentry[4].body != NULL)
1002
	if (hentry[4].body != NULL)
1003
		conv_unmime_header_overwrite(hentry[4].body);
1003
		conv_unmime_header_overwrite(hentry[4].body, strlen(hentry[4].body));
1004
	content_start = ftell(fp);
1004
	content_start = ftell(fp);
1005
	fclose(fp);
1005
	fclose(fp);
1006
1006
Lines 1086-1096 Link Here
1086
			}
1086
			}
1087
			procheader_get_header_fields(fp, hentry);
1087
			procheader_get_header_fields(fp, hentry);
1088
			if (hentry[0].body != NULL)
1088
			if (hentry[0].body != NULL)
1089
				conv_unmime_header_overwrite(hentry[0].body);
1089
				conv_unmime_header_overwrite(hentry[0].body, strlen(hentry[0].body));
1090
			if (hentry[2].body != NULL)
1090
			if (hentry[2].body != NULL)
1091
				conv_unmime_header_overwrite(hentry[2].body);
1091
				conv_unmime_header_overwrite(hentry[2].body, strlen(hentry[2].body));
1092
			if (hentry[4].body != NULL)
1092
			if (hentry[4].body != NULL)
1093
				conv_unmime_header_overwrite(hentry[4].body);
1093
				conv_unmime_header_overwrite(hentry[4].body, strlen(hentry[4].body));
1094
			lastoffset = ftell(fp);
1094
			lastoffset = ftell(fp);
1095
		}
1095
		}
1096
	}
1096
	}
(-)sylpheed-claws-0.9.12.orig/src/unmime.c (-6 / +29 lines)
Lines 34-40 Link Here
34
34
35
/* Decodes headers based on RFC2045 and RFC2047. */
35
/* Decodes headers based on RFC2045 and RFC2047. */
36
36
37
void unmime_header(gchar *out, const gchar *str)
37
void unmime_header(gchar *out, const gchar *str, size_t outsize)
38
{
38
{
39
	const gchar *p = str;
39
	const gchar *p = str;
40
	gchar *outp = out;
40
	gchar *outp = out;
Lines 44-77 Link Here
44
	gchar encoding;
44
	gchar encoding;
45
	gchar *conv_str;
45
	gchar *conv_str;
46
	gint len;
46
	gint len;
47
	size_t cnt;
47
48
48
	while (*p != '\0') {
49
	cnt = 0;
50
	while (*p != '\0' && cnt < outsize) {
49
		gchar *decoded_text = NULL;
51
		gchar *decoded_text = NULL;
50
52
51
		eword_begin_p = strstr(p, ENCODED_WORD_BEGIN);
53
		eword_begin_p = strstr(p, ENCODED_WORD_BEGIN);
52
		if (!eword_begin_p) {
54
		if (!eword_begin_p) {
53
			strcpy(outp, p);
55
			strncpy(outp, p, outsize);
54
			return;
56
			return;
55
		}
57
		}
56
		encoding_begin_p = strchr(eword_begin_p + 2, '?');
58
		encoding_begin_p = strchr(eword_begin_p + 2, '?');
57
		if (!encoding_begin_p) {
59
		if (!encoding_begin_p) {
58
			strcpy(outp, p);
60
			strncpy(outp, p, outsize);
59
			return;
61
			return;
60
		}
62
		}
61
		text_begin_p = strchr(encoding_begin_p + 1, '?');
63
		text_begin_p = strchr(encoding_begin_p + 1, '?');
62
		if (!text_begin_p) {
64
		if (!text_begin_p) {
63
			strcpy(outp, p);
65
			strncpy(outp, p, outsize);
64
			return;
66
			return;
65
		}
67
		}
66
		eword_end_p = strstr(text_begin_p + 1, ENCODED_WORD_END);
68
		eword_end_p = strstr(text_begin_p + 1, ENCODED_WORD_END);
67
		if (!eword_end_p) {
69
		if (!eword_end_p) {
68
			strcpy(outp, p);
70
			strncpy(outp, p, outsize);
69
			return;
71
			return;
70
		}
72
		}
71
73
72
		if (p == str) {
74
		if (p == str) {
75
			if((eword_begin_p - p) >= outsize)
76
				return;
73
			memcpy(outp, p, eword_begin_p - p);
77
			memcpy(outp, p, eword_begin_p - p);
74
			outp += eword_begin_p - p;
78
			outp += eword_begin_p - p;
79
			outsize -= (eword_begin_p - p);
75
			p = eword_begin_p;
80
			p = eword_begin_p;
76
		} else {
81
		} else {
77
			/* ignore spaces between encoded words */
82
			/* ignore spaces between encoded words */
Lines 79-86 Link Here
79
84
80
			for (sp = p; sp < eword_begin_p; sp++) {
85
			for (sp = p; sp < eword_begin_p; sp++) {
81
				if (!isspace(*(const guchar *)sp)) {
86
				if (!isspace(*(const guchar *)sp)) {
87
					if((eword_begin_p - p) >= outsize)
88
						return;
82
					memcpy(outp, p, eword_begin_p - p);
89
					memcpy(outp, p, eword_begin_p - p);
83
					outp += eword_begin_p - p;
90
					outp += eword_begin_p - p;
91
					outsize -= (eword_begin_p - p);
84
					p = eword_begin_p;
92
					p = eword_begin_p;
85
					break;
93
					break;
86
				}
94
				}
Lines 106-113 Link Here
106
				(decoded_text, text_begin_p + 1,
114
				(decoded_text, text_begin_p + 1,
107
				 eword_end_p - (text_begin_p + 1));
115
				 eword_end_p - (text_begin_p + 1));
108
		} else {
116
		} else {
117
			if((eword_end_p + 2 - p) >= outsize)
118
				return;
109
			memcpy(outp, p, eword_end_p + 2 - p);
119
			memcpy(outp, p, eword_end_p + 2 - p);
110
			outp += eword_end_p + 2 - p;
120
			outp += eword_end_p + 2 - p;
121
			outsize -= (eword_end_p + 2 - p);
111
			p = eword_end_p + 2;
122
			p = eword_end_p + 2;
112
			continue;
123
			continue;
113
		}
124
		}
Lines 116-128 Link Here
116
		conv_str = conv_codeset_strdup(decoded_text, charset, NULL);
127
		conv_str = conv_codeset_strdup(decoded_text, charset, NULL);
117
		if (conv_str) {
128
		if (conv_str) {
118
			len = strlen(conv_str);
129
			len = strlen(conv_str);
130
			if(len >= outsize)
131
			{
132
				g_free(decoded_text);
133
				g_free(conv_str);
134
				return;
135
			}
119
			memcpy(outp, conv_str, len);
136
			memcpy(outp, conv_str, len);
120
			g_free(conv_str);
137
			g_free(conv_str);
121
		} else {
138
		} else {
122
			len = strlen(decoded_text);
139
			len = strlen(decoded_text);
140
			if(len >= outsize)
141
			{
142
				g_free(decoded_text);
143
				return;
144
			}
123
			conv_localetodisp(outp, len + 1, decoded_text);
145
			conv_localetodisp(outp, len + 1, decoded_text);
124
		}
146
		}
125
		outp += len;
147
		outp += len;
148
		outsize -= len;
126
149
127
		g_free(decoded_text);
150
		g_free(decoded_text);
128
151
(-)sylpheed-claws-0.9.12.orig/src/unmime.h (-1 / +2 lines)
Lines 23-29 Link Here
23
#include <glib.h>
23
#include <glib.h>
24
24
25
void unmime_header			(gchar		*out,
25
void unmime_header			(gchar		*out,
26
					 const gchar	*str);
26
					 const gchar	*str,
27
					size_t		outsize);
27
gint unmime_quoted_printable_line	(gchar		*str);
28
gint unmime_quoted_printable_line	(gchar		*str);
28
29
29
#endif /* __UNMIME_H__ */
30
#endif /* __UNMIME_H__ */

Return to bug 72801