1
Description: fix denial of service and possible code execution via
2
overflow in _asn1_ltostr
3
Origin: backport, http://git.savannah.gnu.org/gitweb/?p=libtasn1.git;a=commit;h=e47b2a0651ffe1867c844968ade7f6127957bf13
4
Origin: backport, http://git.savannah.gnu.org/gitweb/?p=libtasn1.git;a=commitdiff;h=4d4f992826a4962790ecd0cce6fbba4a415ce149
6
Index: libtasn1-3-2.4/lib/coding.c
7
===================================================================
8
--- libtasn1-3-2.4.orig/lib/coding.c 2015-04-02 11:27:46.846135766 -0400
9
+++ libtasn1-3-2.4/lib/coding.c 2015-04-02 11:36:09.974124773 -0400
12
#define MAX_TAG_LEN 16
15
+# define MAX(a,b) ((a) > (b) ? (a) : (b))
18
/******************************************************/
19
/* Function : _asn1_error_description_value_not_found */
20
/* Description: creates the ErrorDescription string */
24
int tag_len, is_tag_implicit;
25
- unsigned char class, class_implicit = 0, temp[SIZEOF_UNSIGNED_INT * 3 + 1];
26
+ unsigned char class, class_implicit = 0, temp[MAX(SIZEOF_UNSIGNED_INT * 3 + 1, LTOSTR_MAX_SIZE)];
27
unsigned long tag_implicit = 0;
28
char tag_der[MAX_TAG_LEN];
31
char *ErrorDescription)
33
ASN1_TYPE node, p, p2;
34
- char temp[SIZEOF_UNSIGNED_LONG_INT * 3 + 1];
35
+ char temp[MAX(LTOSTR_MAX_SIZE, SIZEOF_UNSIGNED_LONG_INT * 3 + 1)];
36
int counter, counter_old, len2, len3, tlen, move, max_len, max_len_old;
38
unsigned char *der = ider;
39
Index: libtasn1-3-2.4/lib/decoding.c
40
===================================================================
41
--- libtasn1-3-2.4.orig/lib/decoding.c 2015-04-02 11:27:46.846135766 -0400
42
+++ libtasn1-3-2.4/lib/decoding.c 2015-04-02 11:27:46.846135766 -0400
48
+ char temp[LTOSTR_MAX_SIZE];
49
unsigned long val, val1, prev_val;
52
Index: libtasn1-3-2.4/lib/element.c
53
===================================================================
54
--- libtasn1-3-2.4.orig/lib/element.c 2015-04-02 11:27:46.846135766 -0400
55
+++ libtasn1-3-2.4/lib/element.c 2015-04-02 11:27:46.846135766 -0400
57
_asn1_append_sequence_set (ASN1_TYPE node)
61
+ char temp[LTOSTR_MAX_SIZE];
64
if (!node || !(node->down))
65
Index: libtasn1-3-2.4/lib/parser_aux.c
66
===================================================================
67
--- libtasn1-3-2.4.orig/lib/parser_aux.c 2015-04-02 11:27:46.846135766 -0400
68
+++ libtasn1-3-2.4/lib/parser_aux.c 2015-04-02 11:27:46.846135766 -0400
73
-_asn1_ltostr (long v, char *str)
74
+_asn1_ltostr (long v, char str[LTOSTR_MAX_SIZE])
78
+ char temp[LTOSTR_MAX_SIZE];
87
+ while (v && ((start+count) < LTOSTR_MAX_SIZE-1));
89
for (k = 0; k < count; k++)
90
str[k + start] = temp[start + count - k - 1];
91
Index: libtasn1-3-2.4/lib/parser_aux.h
92
===================================================================
93
--- libtasn1-3-2.4.orig/lib/parser_aux.h 2015-04-02 11:27:46.846135766 -0400
94
+++ libtasn1-3-2.4/lib/parser_aux.h 2015-04-02 11:27:46.846135766 -0400
97
void _asn1_delete_list_and_nodes (void);
99
-char *_asn1_ltostr (long v, char *str);
100
+/* Max 64-bit integer length is 20 chars + 1 for sign + 1 for null termination */
101
+#define LTOSTR_MAX_SIZE 22
102
+char *_asn1_ltostr (long v, char str[LTOSTR_MAX_SIZE]);
104
ASN1_TYPE _asn1_find_up (ASN1_TYPE node);