~ubuntu-branches/ubuntu/raring/maradns/raring

« back to all changes in this revision

Viewing changes to update/1.2.12.02/maradns-1.2.12.01-truncation_bugs.patch

  • Committer: Bazaar Package Importer
  • Author(s): Kai Hendry
  • Date: 2010-01-24 12:17:40 UTC
  • mfrom: (1.1.13 upstream) (10.1.4 sid)
  • Revision ID: james.westby@ubuntu.com-20100124121740-a4e1fjobwaouz443
Tags: 1.4.02-1
New upstream release

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
diff -ur maradns-1.2.12.02.orig/dns/Compress.c maradns-1.2.12.02/dns/Compress.c
2
 
--- maradns-1.2.12.02.orig/dns/Compress.c       2005-10-06 15:58:58.000000000 -0500
3
 
+++ maradns-1.2.12.02/dns/Compress.c    2006-08-09 09:38:02.000000000 -0500
4
 
@@ -1,4 +1,4 @@
5
 
-/* Copyright (c) 2002 Sam Trenholme
6
 
+/* Copyright (c) 2002-2006 Sam Trenholme
7
 
  *
8
 
  * TERMS
9
 
  *
10
 
@@ -83,7 +83,7 @@
11
 
     new->uncompressed = uncompressed;
12
 
 
13
 
     /* Initialize the values which allocate memory */
14
 
-    if((new->compressed = js_create(MAX_COMPRESSED_LEN + 3,1)) == 0) {
15
 
+    if((new->compressed = js_create(MAX_COMPRESSED_LEN + 4,1)) == 0) {
16
 
         js_dealloc(new);
17
 
        return 0;
18
 
        }
19
 
@@ -647,7 +647,7 @@
20
 
        return JS_ERROR;
21
 
        }
22
 
     state->uncompressed_offset += 2;
23
 
-    if(state->uncompressed_offset >= state->uncompressed->unit_count) {
24
 
+    if(state->uncompressed_offset > state->uncompressed->unit_count) {
25
 
         state->valid_state = 0;
26
 
        return JS_ERROR;
27
 
        }
28
 
@@ -812,6 +812,7 @@
29
 
  */
30
 
 
31
 
 int compress_get_question(compress_state *state) {
32
 
+
33
 
     /* Sanity checks */
34
 
     if(state->valid_state != 1) {
35
 
         return JS_ERROR;
36
 
@@ -821,6 +822,10 @@
37
 
        return JS_ERROR;
38
 
        }
39
 
 
40
 
+    if(state->number_answers == -2) { /* No questions nor answers */
41
 
+       return JS_SUCCESS;
42
 
+       }
43
 
+
44
 
     /* The domain name question */
45
 
     if(compress_dlabel(state) != JS_SUCCESS) {
46
 
         state->valid_state = 0;
47
 
diff -ur maradns-1.2.12.02.orig/dns/Queries.c maradns-1.2.12.02/dns/Queries.c
48
 
--- maradns-1.2.12.02.orig/dns/Queries.c        2006-07-26 10:58:44.000000000 -0500
49
 
+++ maradns-1.2.12.02/dns/Queries.c     2006-08-09 09:38:02.000000000 -0500
50
 
@@ -1000,6 +1000,8 @@
51
 
          * thing */
52
 
 
53
 
        if(hdr.tc == 1 || (ns == 0 && ar == 0)) {
54
 
+               hdr.tc = 1;
55
 
+               hdr.qdcount = hdr.ancount = hdr.nscount = hdr.arcount = 0;
56
 
                make_hdr(&hdr,packet);
57
 
                return packet;
58
 
        }
59
 
@@ -1008,11 +1010,13 @@
60
 
         count = an + ns + ar;
61
 
        offset = 12; /* Beginning of first question */
62
 
        /* Jump past all of the questions */
63
 
-        while(qc > 1) {
64
 
+        while(qc > 0) {
65
 
                int len;
66
 
                len = dlabel_length(packet,offset);
67
 
                if(len == JS_ERROR) {
68
 
                        hdr.tc = 1;
69
 
+                       hdr.qdcount = hdr.ancount = hdr.nscount = 
70
 
+                               hdr.arcount = 0;
71
 
                        make_hdr(&hdr,packet);
72
 
                        return packet;
73
 
                }
74
 
@@ -1020,6 +1024,8 @@
75
 
                offset += len;
76
 
                if(offset >= packet->unit_count) {
77
 
                        hdr.tc = 1;
78
 
+                       hdr.qdcount = hdr.ancount = hdr.nscount = 
79
 
+                               hdr.arcount = 0;
80
 
                        make_hdr(&hdr,packet);
81
 
                        return packet;
82
 
                }
83
 
@@ -1027,11 +1033,13 @@
84
 
        }
85
 
 
86
 
        /* Jump past all of the answers except for the last one */      
87
 
-       while(count > 2) {
88
 
+       while(count > 1) {
89
 
                int len;
90
 
                len = dlabel_length(packet,offset);
91
 
                if(len == JS_ERROR) {
92
 
                        hdr.tc = 1;
93
 
+                       hdr.qdcount = hdr.ancount = hdr.nscount = 
94
 
+                               hdr.arcount = 0;
95
 
                        make_hdr(&hdr,packet);
96
 
                        return packet;
97
 
                }
98
 
@@ -1039,6 +1047,8 @@
99
 
                offset += len;
100
 
                if(offset + 2 >= packet->unit_count) {
101
 
                        hdr.tc = 1;
102
 
+                       hdr.qdcount = hdr.ancount = hdr.nscount = 
103
 
+                               hdr.arcount = 0;
104
 
                        make_hdr(&hdr,packet);
105
 
                        return packet;
106
 
                }
107
 
@@ -1049,6 +1059,8 @@
108
 
                offset += len + 2;
109
 
                if(offset >= packet->unit_count) {
110
 
                        hdr.tc = 1;
111
 
+                       hdr.qdcount = hdr.ancount = hdr.nscount = 
112
 
+                               hdr.arcount = 0;
113
 
                        make_hdr(&hdr,packet);
114
 
                        return packet;
115
 
                }
116
 
@@ -1065,6 +1077,7 @@
117
 
                hdr.nscount = ns;
118
 
        } else {                
119
 
                hdr.tc = 1;
120
 
+               hdr.qdcount = hdr.ancount = hdr.nscount = hdr.arcount = 0;
121
 
                make_hdr(&hdr,packet);
122
 
                return packet;
123
 
        }
124
 
@@ -1075,8 +1088,4 @@
125
 
        return packet;
126
 
 
127
 
 }
128
 
-
129
 
-       
130
 
-       
131
 
-               
132
 
                
133
 
diff -ur maradns-1.2.12.02.orig/server/MaraDNS.c maradns-1.2.12.02/server/MaraDNS.c
134
 
--- maradns-1.2.12.02.orig/server/MaraDNS.c     2006-08-09 09:37:33.000000000 -0500
135
 
+++ maradns-1.2.12.02/server/MaraDNS.c  2006-08-09 09:39:51.000000000 -0500
136
 
@@ -520,6 +520,7 @@
137
 
     int seen_ptr_record = 0;
138
 
     rr *top = where;
139
 
     int is_auth = 0;
140
 
+    int compress_error_happened = 0;
141
 
 
142
 
     q_header header;
143
 
 
144
 
@@ -926,40 +927,19 @@
145
 
         goto giveerror;
146
 
         }
147
 
 
148
 
-    /* Compress "most" and place the compressed data in "ar" */
149
 
+    compress_error_happened = 0;
150
 
     if(compress_data(most,ar) == JS_ERROR) {
151
 
-        /* This is a bit of a kludge to work around the news.com.com
152
 
-           problem for the 1.0.00 release */
153
 
-        if(log_level > 2) {
154
 
-            log_lock();
155
 
-            show_timestamp();
156
 
-            printf("%s",L_COMPRESS_ERROR);
157
 
-            /* Compress error */
158
 
-            show_esc_stdout(most);
159
 
-            printf("\n");
160
 
-            log_unlock();
161
 
-            }
162
 
-        if(js_copy(most,ar) == JS_ERROR) {
163
 
-            js_destroy(ar);
164
 
-           if(client != 0) {
165
 
-                udperror(sock,most,client,0,SERVER_FAIL,"Compress failure",2,
166
 
-                           rd_value,0);
167
 
-              } else {
168
 
-                udperror(sock,most,0,0,SERVER_FAIL,"Compress failure",2,
169
 
-                           rd_value,ect);
170
 
-                }
171
 
-            js_destroy(most);
172
 
-            return JS_ERROR;
173
 
-            }
174
 
-        }
175
 
+        compress_error_happened = 1;
176
 
+    }
177
 
 
178
 
     /* Check to make sure the data fits in under 512 bytes (4096 bytes
179
 
      * if it's a long_packet_ipv4 address) truncate if not */
180
 
-    if(ar->unit_count > 512) {
181
 
+    if(ar->unit_count > 512 || compress_error_happened == 1) {
182
 
        int x;
183
 
 #ifdef AUTHONLY
184
 
        
185
 
-       if(ect->type == 4) { /* If this is an ipv4 connection */
186
 
+        /* If this is an ipv4 connection and we didn't get a compress error */
187
 
+       if(ect->type == 4 && compress_error_happened == 0) { 
188
 
             struct sockaddr_in *dq;
189
 
            uint32 ip_test;
190
 
            dq = (struct sockaddr_in *)(ect->d);
191
 
@@ -975,16 +955,26 @@
192
 
 #endif
193
 
 
194
 
        for(x = 0; x < 20; x++) {               
195
 
+                compress_error_happened = 0;
196
 
                /* OK, try to squeeze the packet in by removing records */
197
 
                if(squeeze_to_fit(most) == 0) {
198
 
                        goto giveerror;         
199
 
                }
200
 
-               if(compress_data(most,ar) == JS_ERROR) {
201
 
+                if(most->unit_count > 12) {
202
 
+                       if(compress_data(most,ar) == JS_ERROR) {
203
 
+                               compress_error_happened = 1;
204
 
+                       }
205
 
+                       if(ar->unit_count <= 512 && 
206
 
+                           compress_error_happened == 0) {
207
 
+                               break;
208
 
+                       }
209
 
+                } else if(most->unit_count == 12) {
210
 
+                       if(js_copy(most,ar) == JS_ERROR) {
211
 
+                               goto giveerror;
212
 
+                       }
213
 
+               } else {
214
 
                        goto giveerror;
215
 
                }
216
 
-               if(ar->unit_count <= 512) {
217
 
-                       break;
218
 
-               }
219
 
            }
220
 
         }
221
 
 
222
 
@@ -992,6 +982,10 @@
223
 
 long_packet_ok:
224
 
 #endif
225
 
 
226
 
+    if(compress_error_happened == 1) {
227
 
+       goto giveerror;
228
 
+    }
229
 
+
230
 
     /* Success! Put out the good data */
231
 
     if(ect == 0) {
232
 
         sendto(sock,ar->string,ar->unit_count,0,
233
 
diff -ur maradns-1.2.12.02.orig/tools/askmara.c maradns-1.2.12.02/tools/askmara.c
234
 
--- maradns-1.2.12.02.orig/tools/askmara.c      2006-06-11 02:16:32.000000000 -0500
235
 
+++ maradns-1.2.12.02/tools/askmara.c   2006-08-09 09:38:02.000000000 -0500
236
 
@@ -542,6 +542,10 @@
237
 
     if(read_hdr(uindata,&header) == JS_ERROR)
238
 
         harderror(L_INHEADER_CONV); /* Problem converting inheader */
239
 
 
240
 
+    if(header.tc == 1) {
241
 
+       printf("# Remote server said: TRUNCATED\n");
242
 
+    }
243
 
+
244
 
     /* If not 0, show them the rcode from the remote server */
245
 
     switch(header.rcode) {
246
 
        case 1: