Imported Debian patch 4.84-8
[hcoop/debian/exim4.git] / debian / patches / 80_mime_empty_charset.diff
1 From 93cad488cb2c9a31aea345c8910a9f9c5815071c Mon Sep 17 00:00:00 2001
2 From: Jeremy Harris <jgh146exb@wizmail.org>
3 Date: Fri, 29 Aug 2014 14:11:50 +0100
4 Subject: [PATCH] Fix crash in mime acl when a parameter is zero-length
5
6
7 diff --git a/src/mime.c b/src/mime.c
8 index 95d3da4..ab701f2 100644
9 --- a/src/mime.c
10 +++ b/src/mime.c
11 @@ -620,12 +620,18 @@ NEXT_PARAM_SEARCH:
12 else
13 param_value = string_cat(param_value, &size, &ptr, q++, 1);
14 }
15 - param_value[ptr++] = '\0';
16 - param_value_len = ptr;
17 -
18 - param_value = rfc2047_decode(param_value, check_rfc2047_length, NULL, 32, &param_value_len, &q);
19 - debug_printf("Found %s MIME parameter in %s header, value is '%s'\n", mp->name, mime_header_list[i].name, param_value);
20 - *((uschar **)(mp->value)) = param_value;
21 + if (param_value)
22 + {
23 + param_value[ptr++] = '\0';
24 + param_value_len = ptr;
25 +
26 + param_value = rfc2047_decode(param_value,
27 + check_rfc2047_length, NULL, 32, &param_value_len, &q);
28 + debug_printf("Found %s MIME parameter in %s header, "
29 + "value is '%s'\n", mp->name, mime_header_list[i].name,
30 + param_value);
31 + }
32 + *mp->value = param_value;
33 p += (mp->namelen + param_value_len + 1);
34 goto NEXT_PARAM_SEARCH;
35 }
36 diff --git a/src/mime.h b/src/mime.h
37 index abf68da..af09f67 100644
38 --- a/src/mime.h
39 +++ b/src/mime.h
40 @@ -40,15 +40,15 @@ static int mime_header_list_size = sizeof(mime_header_list)/sizeof(mime_header);
41
42
43 typedef struct mime_parameter {
44 - uschar *name;
45 - int namelen;
46 - void *value;
47 + uschar * name;
48 + int namelen;
49 + uschar ** value;
50 } mime_parameter;
51
52 static mime_parameter mime_parameter_list[] = {
53 - { US"name=", 5, &mime_filename },
54 + { US"name=", 5, &mime_filename },
55 { US"filename=", 9, &mime_filename },
56 - { US"charset=", 8, &mime_charset },
57 + { US"charset=", 8, &mime_charset },
58 { US"boundary=", 9, &mime_boundary }
59 };
60