~ubuntu-branches/ubuntu/trusty/maradns/trusty-proposed

« back to all changes in this revision

Viewing changes to deadwood-3.2.05/update/3.2.02/deadwood-3.2.01-max_ttl.patch

  • Committer: Package Import Robot
  • Author(s): Dariusz Dwornikowski
  • Date: 2014-02-16 19:36:04 UTC
  • mfrom: (1.2.11) (21.1.11 experimental)
  • Revision ID: package-import@ubuntu.com-20140216193604-xtmcopn9pilzszae
Tags: 2.0.09-1
* New maintainer (Closes: #739084)
* New upstream release to unstable
* Several security bugs (Closes: #739755)
   - security bugfix for CVE-2011-5055, CVE-2011-5056, CVE-2012-0024,
   CVE-2012-1570
   - security bugfix agains blind spoofing attack (no CVE number)
   - security bugfix for packet of death attack (no CVE number)
* Bump standards to 3.9.5
* Updated d/postinst to no longer modify conffiles (Closes: #710903)
* Init script fixed (Closes: #709826)
* --reinstall no longer kills the process (Closes: #701657)
* Updated old d/changelog entries, added information when the CVEs were
  fixed: 2.0.06-1, 2.0.04-1, 1.4.11-1, 1.2.12.06-1, 1.2.12.05-1, 1.0.28-1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
--- deadwood-3.2.01/src/DwUdpSocket.c   2012-02-11 14:15:43.000000000 -0600
 
2
+++ deadwood-3.2.02/src/DwUdpSocket.c   2012-02-12 12:38:07.000000000 -0600
 
3
@@ -56,6 +56,7 @@
 
4
 extern int min_bind;
 
5
 extern int num_ports;
 
6
 extern int num_retries;
 
7
+extern int32_t max_ttl;
 
8
 
 
9
 /* Other mararc parameters */
 
10
 extern dwd_dict *blacklist_dict;
 
11
@@ -813,6 +814,9 @@
 
12
         } else {
 
13
                 answer = dw_packet_to_cache(packet,count,is_nxdomain);
 
14
                 decomp = dwc_decompress(question,answer);
 
15
+               if(decomp == 0) {
 
16
+                        goto catch_cache_dns_reply;
 
17
+                }
 
18
                 if(dwc_has_bad_ip(decomp,blacklist_dict)) {
 
19
                         ret = -2; /* Tell caller we need synth "not there" */
 
20
                         goto catch_cache_dns_reply;
 
21
@@ -836,6 +840,9 @@
 
22
                 if(ttl < 30) {
 
23
                         ttl = 30;
 
24
                 }
 
25
+               if(ttl > max_ttl) {
 
26
+                       ttl = max_ttl;
 
27
+               }
 
28
 
 
29
                 /* Routines in DwRecurse.c process the packet and let us know
 
30
                  * what kind of packet we got upstream (so we know how to
 
31
--- deadwood-3.2.01/src/DwMararc.h      2012-02-11 14:15:43.000000000 -0600
 
32
+++ deadwood-3.2.02/src/DwMararc.h      2012-02-12 12:34:20.000000000 -0600
 
33
@@ -1,4 +1,4 @@
 
34
-/* Copyright (c) 2007-2011 Sam Trenholme
 
35
+/* Copyright (c) 2007-2012 Sam Trenholme
 
36
  *
 
37
  * TERMS
 
38
  *
 
39
@@ -67,13 +67,14 @@
 
40
 #define DWM_N_truncation_hack 26
 
41
 #define DWM_N_reject_ptr 27
 
42
 #define DWM_N_min_ttl_incomplete_cname 28
 
43
+#define DWM_N_max_ttl 29
 
44
 
 
45
 /* Number of string parameters in the mararc file */
 
46
 #define KEY_S_COUNT 7
 
47
 /* Number of dictionary parameters in the mararc file */
 
48
 #define KEY_D_COUNT 2
 
49
 /* Number of numeric parameters in the mararc file */
 
50
-#define KEY_N_COUNT 29
 
51
+#define KEY_N_COUNT 30
 
52
 
 
53
 #ifndef MINGW
 
54
 /* Location of files we read when we run execfile("foo") */
 
55
@@ -147,6 +148,7 @@
 
56
                          synthetic "not there" reply */
 
57
         "min_ttl_incomplete_cname", /* How long to store incomplete CNAME
 
58
                                      * records in the cache, in seconds */
 
59
+       "max_ttl", /* Maximum allowed TTL */
 
60
         0 };
 
61
 
 
62
 #endif /* MARARC_C */
 
63
--- deadwood-3.2.01/src/DwRecurse.c     2012-02-11 14:15:43.000000000 -0600
 
64
+++ deadwood-3.2.02/src/DwRecurse.c     2012-02-12 12:36:27.000000000 -0600
 
65
@@ -1,4 +1,4 @@
 
66
-/* Copyright (c) 2009-2011 Sam Trenholme
 
67
+/* Copyright (c) 2009-2012 Sam Trenholme
 
68
  *
 
69
  * TERMS
 
70
  *
 
71
@@ -49,6 +49,8 @@
 
72
 #ifdef MINGW
 
73
 extern u_long dont_block;
 
74
 #endif /* MINGW */
 
75
+/* Numeric mararc parameters */
 
76
+extern int32_t max_ttl;
 
77
 
 
78
 #ifdef OTHER_STUFF
 
79
 /* Show a single character on the standard output, escaping the
 
80
@@ -1658,6 +1660,9 @@
 
81
                           * an hour for security reasons */
 
82
                 ttl = 3600;
 
83
         }
 
84
+       if(ttl > max_ttl) {
 
85
+               ttl = max_ttl;
 
86
+       }
 
87
         dw_put_u16(place, 65395, -1); /* Add "NS refer" private RR type */
 
88
         dwh_add(cache,place,action,ttl,1);
 
89
 
 
90
@@ -2018,6 +2023,9 @@
 
91
         if(ttl < 60) {
 
92
                 ttl = 60;
 
93
         }
 
94
+       if(ttl > max_ttl) {
 
95
+               ttl = max_ttl;
 
96
+       }
 
97
         /*ttl = 30; // DEBUG*/
 
98
         uncomp = dwx_create_cname_reply(query, action, answer, ttl);
 
99
         comp = dwc_compress(query, uncomp);
 
100
@@ -2088,6 +2096,12 @@
 
101
         if(ttl < key_n[DWM_N_min_ttl_incomplete_cname]) {
 
102
                 ttl = key_n[DWM_N_min_ttl_incomplete_cname];
 
103
         }
 
104
+       if(ttl < 30) {
 
105
+               ttl = 30;
 
106
+       }
 
107
+       if(ttl > max_ttl) {
 
108
+               ttl = max_ttl;
 
109
+       }
 
110
         cname_cache=dw_copy(query);
 
111
         if(cname_cache == 0 || cname_cache->len < 3 ||
 
112
                         dw_put_u16(cname_cache, 65394, -3) == -1) {
 
113
@@ -2164,6 +2178,13 @@
 
114
                 goto catch_dwx_cache_reply;
 
115
         }
 
116
 
 
117
+       if(ttl < 30) {
 
118
+               ttl = 30;
 
119
+       }
 
120
+       if(ttl > max_ttl) {
 
121
+               ttl = max_ttl;
 
122
+       }
 
123
+
 
124
         bailiwick = dw_get_dname(rem[connection_number].ns->str, 0, 260);
 
125
         if(bailiwick == 0 || bailiwick->len > 256) {
 
126
                 goto catch_dwx_cache_reply;
 
127
--- deadwood-3.2.01/src/DwMararc.c      2012-02-11 14:15:43.000000000 -0600
 
128
+++ deadwood-3.2.02/src/DwMararc.c      2012-02-12 12:34:20.000000000 -0600
 
129
@@ -400,6 +400,7 @@
 
130
         key_n[DWM_N_truncation_hack] = 1;
 
131
         key_n[DWM_N_reject_ptr] = 0;
 
132
         key_n[DWM_N_min_ttl_incomplete_cname] = 3600;
 
133
+        key_n[DWM_N_max_ttl] = 86400;
 
134
 }
 
135
 
 
136
 /* Look for a Mararc parameter; -1 if not found/error; 0-n if found
 
137
--- deadwood-3.2.01/src/DwSocket.c      2012-02-11 14:15:43.000000000 -0600
 
138
+++ deadwood-3.2.02/src/DwSocket.c      2012-02-12 12:34:20.000000000 -0600
 
139
@@ -71,6 +71,7 @@
 
140
 int32_t num_ports = 4096;
 
141
 int32_t maradns_uid = 99;
 
142
 int32_t maradns_gid = 99;
 
143
+int32_t max_ttl = 86400;
 
144
 int num_retries = 5;
 
145
 dwd_dict *blacklist_dict = 0;
 
146
 
 
147
@@ -500,6 +501,10 @@
 
148
         maradns_gid = get_key_n(DWM_N_maradns_gid,10,65535,99);
 
149
         resurrections = get_key_n(DWM_N_resurrections,0,1,1);
 
150
         num_retries = get_key_n(DWM_N_num_retries,0,32,5);
 
151
+       max_ttl = get_key_n(DWM_N_max_ttl,
 
152
+               300 /* 5 minutes */,
 
153
+               7776000 /* 90 days */,
 
154
+               86400 /* One day */);
 
155
 
 
156
         if((num_ports & (num_ports - 1)) != 0) {
 
157
                 dw_fatal("num_ports must be a power of 2");
 
158
--- deadwood-3.2.01/doc/Deadwood.ej     2012-02-11 14:15:43.000000000 -0600
 
159
+++ deadwood-3.2.02/doc/Deadwood.ej     2012-02-12 12:34:20.000000000 -0600
 
160
@@ -232,6 +232,21 @@
 
161
 
 
162
 The default value is 8.
 
163
 
 
164
+<h2>max_ttl</h2>
 
165
+The maximum amount of time we will keep an entry in the cache, in seconds.
 
166
+
 
167
+<p>
 
168
+
 
169
+This is the longest we will keep an entry cached.  The default value for
 
170
+this parameter is 86400 (one day); the minimum value is 300 (5 minutes) and
 
171
+the maximum value this can have is 7776000 (90 days).
 
172
+
 
173
+<p>
 
174
+
 
175
+The reason why this parameter is here is to protect Deadwood from attacks
 
176
+which exploit there being stale data in the cache, such as the 
 
177
+"Ghost Domain Names" attack.
 
178
+
 
179
 <h2>maximum_cache_elements</h2>  
 
180
 The maximum number of elements our cache 
 
181
 is allowed to have.  This is a number between 32 and 16,777,216; 
 
182
--- deadwood-3.2.01/doc/dwood3rc-all    2012-02-11 14:15:43.000000000 -0600
 
183
+++ deadwood-3.2.02/doc/dwood3rc-all    2012-02-12 12:34:20.000000000 -0600
 
184
@@ -62,6 +62,9 @@
 
185
 # Maximum number of TCP connections.  tcp_listen also must be set.
 
186
 max_tcp_procs = 8
 
187
 
 
188
+# Maximum time an entry will stay in the cache, in seconds (86400 = one day)
 
189
+max_ttl = 86400
 
190
+
 
191
 # The number of times we retry to send a query upstream before giving up.
 
192
 num_retries = 2
 
193