~ubuntu-branches/ubuntu/quantal/maradns/quantal

« back to all changes in this revision

Viewing changes to update/2.0.03/maradns-2.0.02-big_any.patch

  • Committer: Package Import Robot
  • Author(s): Iain Lane
  • Date: 2012-01-12 23:35:38 UTC
  • mto: This revision was merged to the branch mainline in revision 26.
  • Revision ID: package-import@ubuntu.com-20120112233538-5jkaqrh9nbqtf1ey
Tags: upstream-2.0.04+really1.4.09
ImportĀ upstreamĀ versionĀ 2.0.04+really1.4.09

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
--- maradns-2.0.02/server/MaraDNS.c     2011-02-05 19:21:40.000000000 -0700
2
 
+++ maradns-2.0.03/server/MaraDNS.c     2011-02-18 15:19:12.000000000 -0700
3
 
@@ -1,4 +1,4 @@
4
 
-/* Copyright (c) 2002-2010 Sam Trenholme
5
 
+/* Copyright (c) 2002-2011 Sam Trenholme
6
 
  *
7
 
  * TERMS
8
 
  *
9
 
@@ -863,7 +863,6 @@
10
 
     int len_inet = sizeof(struct sockaddr);
11
 
     int found = 0;
12
 
     int authoritative = 1;
13
 
-    rr *where = 0;
14
 
     rr_list *answer = 0;
15
 
     mhash_e spot_data;
16
 
     int counter;
17
 
@@ -910,10 +909,6 @@
18
 
     header.nscount = 0;
19
 
     header.arcount = 0;
20
 
 
21
 
-    if(called_from_recursive == 1) {
22
 
-        goto use_old_udpany_code;
23
 
-    }
24
 
-
25
 
     /* Start synthesizing the reply */
26
 
     /* Look for the list of all of the answers */
27
 
     spot_data = mhash_get(bighash,query);
28
 
@@ -1020,228 +1015,6 @@
29
 
     js_destroy(starwhitis);
30
 
     goto old_udpany_code_disabled;
31
 
 
32
 
-use_old_udpany_code:
33
 
-
34
 
-    /* The old udpany code is still used by the recursive half of
35
 
-     * MaraDNS, so we have to keep it for the time being */
36
 
-
37
 
-    /* Look for an A record with the same name as the query */
38
 
-    if(change_rtype(query,RR_A) == JS_ERROR)
39
 
-        goto giveerror;
40
 
-    spot_data = mhash_get(bighash,query);
41
 
-    /* If found, add the data to our records */
42
 
-    if(spot_data.value != 0 && spot_data.datatype == MARA_DNSRR) {
43
 
-        found = 1;
44
 
-        where = spot_data.value;
45
 
-        authoritative = where->authoritative;
46
 
-        if(add_answer(spot_data.value,most,ns,ar,&(header.ancount),
47
 
-                   &(header.nscount),&(header.arcount),1,
48
 
-                   spot_data.point,0,0) == JS_ERROR)
49
 
-            goto giveerror;
50
 
-        }
51
 
-    /* Look for MX record with the same name as the query */
52
 
-    if(change_rtype(query,RR_MX) == JS_ERROR)
53
 
-        goto giveerror;
54
 
-    spot_data = mhash_get(bighash,query);
55
 
-    if(spot_data.value != 0 && spot_data.datatype == MARA_DNSRR) {
56
 
-        if(found == 1) {
57
 
-            if(add_answer(spot_data.value,most,ns,ar,&(header.ancount),
58
 
-               &(header.nscount),&(header.arcount),0,
59
 
-               spot_data.point,0,0) == JS_ERROR)
60
 
-                goto giveerror;
61
 
-            }
62
 
-        else {
63
 
-            where = spot_data.value;
64
 
-            authoritative = where->authoritative;
65
 
-            if(add_answer(spot_data.value,most,ns,ar,&(header.ancount),
66
 
-               &(header.nscount),&(header.arcount),1,
67
 
-               spot_data.point,0,0) == JS_ERROR)
68
 
-                goto giveerror;
69
 
-            }
70
 
-        found = 1;
71
 
-        }
72
 
-
73
 
-    /* We optionally look for NS and SOA on an RR_ANY query */
74
 
-    if(rr_set == 15) {
75
 
-      /* Look for NS record with the same name as the query */
76
 
-      if(change_rtype(query,RR_NS) == JS_ERROR)
77
 
-        goto giveerror;
78
 
-      spot_data = mhash_get(bighash,query);
79
 
-      if(spot_data.value != 0 && spot_data.datatype == MARA_DNSRR) {
80
 
-        if(found == 1) {
81
 
-            if(add_answer(spot_data.value,most,ns,ar,&(header.ancount),
82
 
-               &(header.nscount),&(header.arcount),0,
83
 
-               spot_data.point,0,0) == JS_ERROR)
84
 
-                goto giveerror;
85
 
-            }
86
 
-        else {
87
 
-            where = spot_data.value;
88
 
-            authoritative = where->authoritative;
89
 
-            if(add_answer(spot_data.value,most,ns,ar,&(header.ancount),
90
 
-               &(header.nscount),&(header.arcount),1,
91
 
-               spot_data.point,0,0) == JS_ERROR)
92
 
-                goto giveerror;
93
 
-            }
94
 
-        found = 1;
95
 
-        }
96
 
-      /* Look for SOA record with the same name as the query */
97
 
-      if(change_rtype(query,RR_SOA) == JS_ERROR)
98
 
-        goto giveerror;
99
 
-      spot_data = mhash_get(bighash,query);
100
 
-      if(spot_data.value != 0 && spot_data.datatype == MARA_DNSRR) {
101
 
-        if(found == 1) {
102
 
-            if(add_answer(spot_data.value,most,ns,ar,&(header.ancount),
103
 
-               &(header.nscount),&(header.arcount),0,
104
 
-               spot_data.point,0,0) == JS_ERROR)
105
 
-                goto giveerror;
106
 
-            }
107
 
-        else {
108
 
-            where = spot_data.value;
109
 
-            authoritative = where->authoritative;
110
 
-            if(add_answer(spot_data.value,most,ns,ar,&(header.ancount),
111
 
-               &(header.nscount),&(header.arcount),1,
112
 
-               spot_data.point,0,0) == JS_ERROR)
113
 
-                goto giveerror;
114
 
-            }
115
 
-        found = 1;
116
 
-        }
117
 
-      }
118
 
-
119
 
-    /* If not found, look for lower-case version of the same query */
120
 
-    if(found != 1) {
121
 
-        found = fold_case(query);
122
 
-        if(found == JS_ERROR)
123
 
-            goto giveerror;
124
 
-        if(found == 1) /* Case folded */ {
125
 
-            found = 0;
126
 
-            /* Look for lower case version of A record */
127
 
-            if(change_rtype(query,RR_A) == JS_ERROR)
128
 
-                goto giveerror;
129
 
-            spot_data = mhash_get(bighash,query);
130
 
-            /* If A record of lower-case found... */
131
 
-            if(spot_data.value != 0 && spot_data.datatype == MARA_DNSRR) {
132
 
-                found = 1;
133
 
-                where = spot_data.value;
134
 
-                authoritative = where->authoritative;
135
 
-                if(add_answer(spot_data.value,most,ns,ar,&(header.ancount),
136
 
-                   &(header.nscount),&(header.arcount),1,
137
 
-                   spot_data.point,0,0) == JS_ERROR)
138
 
-                    goto giveerror;
139
 
-                }
140
 
-            if(change_rtype(query,RR_MX) == JS_ERROR)
141
 
-                goto giveerror;
142
 
-            spot_data = mhash_get(bighash,query);
143
 
-            /* If MX record of lower-case found... */
144
 
-            if(spot_data.value != 0 && spot_data.datatype == MARA_DNSRR) {
145
 
-                if(found == 1) {
146
 
-                    if(add_answer(spot_data.value,most,ns,ar,&(header.ancount),
147
 
-                       &(header.nscount),&(header.arcount),0,
148
 
-                       spot_data.point,0,0) == JS_ERROR)
149
 
-                        goto giveerror;
150
 
-                    }
151
 
-                else {
152
 
-                    where = spot_data.value;
153
 
-                    authoritative = where->authoritative;
154
 
-                    if(add_answer(spot_data.value,most,ns,ar,&(header.ancount),
155
 
-                       &(header.nscount),&(header.arcount),1,
156
 
-                       spot_data.point,0,0) == JS_ERROR)
157
 
-                        goto giveerror;
158
 
-                    }
159
 
-                }
160
 
-            /* Optionally look for SOA and NS records */
161
 
-            if(rr_set == 15) {
162
 
-              if(change_rtype(query,RR_NS) == JS_ERROR)
163
 
-                goto giveerror;
164
 
-              spot_data = mhash_get(bighash,query);
165
 
-              /* If NS record of lower-case found... */
166
 
-              if(spot_data.value != 0 && spot_data.datatype == MARA_DNSRR) {
167
 
-                if(found == 1) {
168
 
-                    if(add_answer(spot_data.value,most,ns,ar,&(header.ancount),
169
 
-                       &(header.nscount),&(header.arcount),0,
170
 
-                       spot_data.point,0,0) == JS_ERROR)
171
 
-                        goto giveerror;
172
 
-                    }
173
 
-                else {
174
 
-                    where = spot_data.value;
175
 
-                    authoritative = where->authoritative;
176
 
-                    if(add_answer(spot_data.value,most,ns,ar,&(header.ancount),
177
 
-                       &(header.nscount),&(header.arcount),1,
178
 
-                       spot_data.point,0,0) == JS_ERROR)
179
 
-                        goto giveerror;
180
 
-                    }
181
 
-                }
182
 
-              if(change_rtype(query,RR_SOA) == JS_ERROR)
183
 
-                goto giveerror;
184
 
-              spot_data = mhash_get(bighash,query);
185
 
-              /* If SOA record of lower-case found... */
186
 
-              if(spot_data.value != 0 && spot_data.datatype == MARA_DNSRR) {
187
 
-                if(found == 1) {
188
 
-                    if(add_answer(spot_data.value,most,ns,ar,&(header.ancount),
189
 
-                       &(header.nscount),&(header.arcount),0,
190
 
-                       spot_data.point,0,0) == JS_ERROR)
191
 
-                        goto giveerror;
192
 
-                    }
193
 
-                else {
194
 
-                    where = spot_data.value;
195
 
-                    authoritative = where->authoritative;
196
 
-                    if(add_answer(spot_data.value,most,ns,ar,&(header.ancount),
197
 
-                       &(header.nscount),&(header.arcount),1,
198
 
-                       spot_data.point,0,0) == JS_ERROR)
199
 
-                        goto giveerror;
200
 
-                    }
201
 
-                }
202
 
-              }
203
 
-            }
204
 
-        if(found == 0) { /* If not found, do star record search */
205
 
-                found = starwhitis_seek_any(query,RR_A,0,&header,&where,
206
 
-                                &authoritative,most,ns,ar);
207
 
-                found = starwhitis_seek_any(query,RR_MX,found,&header,
208
 
-                                &where,&authoritative,most,ns,ar);
209
 
-                if(rr_set == 15) {
210
 
-                        found = starwhitis_seek_any(query,RR_NS,found,
211
 
-                                        &header,&where,&authoritative,most,
212
 
-                                        ns,ar);
213
 
-                        found = starwhitis_seek_any(query,RR_SOA,found,
214
 
-                                        &header,&where,&authoritative,most,
215
 
-                                        ns,ar);
216
 
-                }
217
 
-                if(found == JS_ERROR) {
218
 
-                        goto giveerror;
219
 
-                }
220
 
-        }
221
 
-       }
222
 
-
223
 
-    /* If nothing found, look for a CNAME record with the same name as
224
 
-       the query */
225
 
-    if(found == 0) {
226
 
-        if(change_rtype(query,RR_CNAME) == JS_ERROR)
227
 
-            goto giveerror;
228
 
-        spot_data = mhash_get(bighash,query);
229
 
-        /* If found, add the data to our records */
230
 
-        if(spot_data.value != 0 && spot_data.datatype == MARA_DNSRR) {
231
 
-            found = 1;
232
 
-            if(add_answer(spot_data.value,most,ns,ar,&(header.ancount),
233
 
-                         &(header.nscount),&(header.arcount),1,
234
 
-                         spot_data.point,0,0) == JS_ERROR)
235
 
-                goto giveerror;
236
 
-            }
237
 
-        }
238
 
-
239
 
-    /* If nothing found, look for DDIP notation */
240
 
-    if(found == 0) {
241
 
-        if(change_rtype(query,RR_ANY) == JS_ERROR)
242
 
-            goto giveerror;
243
 
-        found = ddip_check(id,sock,ect,query);
244
 
-        if(found == JS_ERROR)
245
 
-            goto giveerror;
246
 
-        if(found == JS_SUCCESS) {
247
 
-            js_destroy(ar);
248
 
-            js_destroy(ns);
249
 
-            js_destroy(most);
250
 
-            return JS_SUCCESS;
251
 
-            }
252
 
-        }
253
 
-
254
 
 old_udpany_code_disabled:
255
 
 
256
 
     /* Return with exit code of 0 if no answer was found */
257
 
@@ -1290,12 +1063,36 @@
258
 
 
259
 
     /* Check to make sure the data fits in under 512 bytes */
260
 
     if(ar->unit_count > 512) {
261
 
+
262
 
+        /* If this is an ipv4 connection and we didn't get a compress error */
263
 
+        if(ect->type == 4) {
264
 
+            struct sockaddr_in *dq;
265
 
+            uint32 ip_test;
266
 
+            dq = (struct sockaddr_in *)(ect->d);
267
 
+            ip_test = ntohl(dq->sin_addr.s_addr);
268
 
+            /* See if we are allowed to send a long packet up to
269
 
+             * 4096 bytes to this ip address */
270
 
+            if(check_ipv4_acl(ip_test,long_packet) == 1) {
271
 
+                if(ar->unit_count < 4096) {
272
 
+                    goto long_packet_ok;
273
 
+                    }
274
 
+                }
275
 
+            }
276
 
+
277
 
         /* We handle truncation by truncating everything except the
278
 
            12-byte header */
279
 
         header.tc = 1;
280
 
+        header.ancount = 0;
281
 
         make_hdr(&header,ar);
282
 
+        /* Append the question, if there is one */
283
 
+        if(query != 0) {
284
 
+           js_append(query,ar);
285
 
+           js_adduint16(ar,1);
286
 
+           }
287
 
         }
288
 
 
289
 
+long_packet_ok:
290
 
+
291
 
     /* Success! Put out the good data */
292
 
     if(ect == 0) {
293
 
         sendto(sock,ar->string,ar->unit_count,0,