~ubuntu-branches/ubuntu/lucid/libtasn1-3/lucid-security

« back to all changes in this revision

Viewing changes to debian/patches/CVE-2015-2806.patch

  • Committer: Package Import Robot
  • Author(s): Marc Deslauriers
  • Date: 2015-04-02 11:27:53 UTC
  • Revision ID: package-import@ubuntu.com-20150402112753-ek5d5e0lzmg7r3mr
Tags: 2.4-1ubuntu0.3
* SECURITY UPDATE: denial of service and possible code execution via
  overflow in _asn1_ltostr
  - debian/patches/CVE-2015-2806.patch: introduce LTOSTR_MAX_SIZE and use
    in lib/coding.c, lib/decoding.c, lib/element.c, lib/parser_aux.c,
    lib/parser_aux.h.
  - CVE-2015-2806

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
 
5
 
 
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
 
10
@@ -35,6 +35,10 @@
 
11
 
 
12
 #define MAX_TAG_LEN 16
 
13
 
 
14
+#ifndef MAX
 
15
+# define MAX(a,b) ((a) > (b) ? (a) : (b))
 
16
+#endif
 
17
+
 
18
 /******************************************************/
 
19
 /* Function : _asn1_error_description_value_not_found */
 
20
 /* Description: creates the ErrorDescription string   */
 
21
@@ -448,7 +452,7 @@
 
22
 {
 
23
   ASN1_TYPE p;
 
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];
 
29
 
 
30
@@ -874,7 +878,7 @@
 
31
                 char *ErrorDescription)
 
32
 {
 
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;
 
37
   asn1_retCode err;
 
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
 
43
@@ -286,7 +286,7 @@
 
44
 {
 
45
   int len_len, len, k;
 
46
   int leading;
 
47
-  char temp[20];
 
48
+  char temp[LTOSTR_MAX_SIZE];
 
49
   unsigned long val, val1, prev_val;
 
50
 
 
51
   *ret_len = 0;
 
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
 
56
@@ -134,7 +134,7 @@
 
57
 _asn1_append_sequence_set (ASN1_TYPE node)
 
58
 {
 
59
   ASN1_TYPE p, p2;
 
60
-  char temp[10];
 
61
+  char temp[LTOSTR_MAX_SIZE];
 
62
   long n;
 
63
 
 
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
 
69
@@ -580,10 +580,10 @@
 
70
 
 
71
 
 
72
 char *
 
73
-_asn1_ltostr (long v, char *str)
 
74
+_asn1_ltostr (long v, char str[LTOSTR_MAX_SIZE])
 
75
 {
 
76
   long d, r;
 
77
-  char temp[20];
 
78
+  char temp[LTOSTR_MAX_SIZE];
 
79
   int count, k, start;
 
80
 
 
81
   if (v < 0)
 
82
@@ -604,7 +604,7 @@
 
83
       count++;
 
84
       v = d;
 
85
     }
 
86
-  while (v);
 
87
+  while (v && ((start+count) < LTOSTR_MAX_SIZE-1));
 
88
 
 
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
 
95
@@ -42,7 +42,9 @@
 
96
 
 
97
 void _asn1_delete_list_and_nodes (void);
 
98
 
 
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]);
 
103
 
 
104
 ASN1_TYPE _asn1_find_up (ASN1_TYPE node);
 
105