1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
$NetBSD: patch-ag,v 1.1 2008/08/31 20:09:12 dholland Exp $
--- src/mime.c~ 2004-08-13 07:18:22.000000000 -0400
+++ src/mime.c 2008-08-31 15:50:42.000000000 -0400
@@ -526,8 +526,9 @@ translate (struct rfc2047 *s, char *to)
{
int ret;
iconv_t id = iconv_open (to, s->charset);
- char *inptr, *outptr, *result;
- int insize, outsize, ressize;
+ const char *inptr;
+ char *outptr, *result;
+ size_t insize, outsize, ressize;
int bad_chars = 0;
if (id == (iconv_t) -1){
@@ -557,10 +558,17 @@ translate (struct rfc2047 *s, char *to)
insize--;
}
if (errno == E2BIG){
+ if (ressize * 2 > ressize) {
result = xrealloc (result, ressize * 2);
outptr += ressize - outsize;
outsize += ressize;
ressize *= 2;
+ } else {
+ /* wrong: should report overflow */
+ /* (but don't want to patch in a new message string) */
+ bad_chars++;
+ insize = 0;
+ }
}
}
|