1 |
vip-ire |
1.1 |
--- djbdns-1.05-original/tdlookup.c Sun Feb 11 21:11:45 2001 |
2 |
|
|
+++ djbdns-1.05/tdlookup.c Thu Apr 3 11:56:47 2003 |
3 |
|
|
@@ -103,12 +103,13 @@ |
4 |
|
|
return response_addname(d1); |
5 |
|
|
} |
6 |
|
|
|
7 |
|
|
-static int doit(char *q,char qtype[2]) |
8 |
|
|
+static int doit1(char **pqname,char qtype[2]) |
9 |
|
|
{ |
10 |
|
|
unsigned int bpos; |
11 |
|
|
unsigned int anpos; |
12 |
|
|
unsigned int aupos; |
13 |
|
|
unsigned int arpos; |
14 |
|
|
+ char *q; |
15 |
|
|
char *control; |
16 |
|
|
char *wild; |
17 |
|
|
int flaggavesoa; |
18 |
|
|
@@ -122,6 +123,12 @@ |
19 |
|
|
int addrnum; |
20 |
|
|
uint32 addrttl; |
21 |
|
|
int i; |
22 |
|
|
+ int loop = 0 ; |
23 |
|
|
+ |
24 |
|
|
+RESTART: |
25 |
|
|
+ if (loop++ >= 100) return 0 ; |
26 |
|
|
+ |
27 |
|
|
+ q = *pqname ; |
28 |
|
|
|
29 |
|
|
anpos = response_len; |
30 |
|
|
|
31 |
|
|
@@ -136,7 +143,14 @@ |
32 |
|
|
if (byte_equal(type,2,DNS_T_NS)) flagns = 1; |
33 |
|
|
} |
34 |
|
|
if (flagns) break; |
35 |
|
|
- if (!*control) return 0; /* q is not within our bailiwick */ |
36 |
|
|
+ if (!*control) { /* q is not within our bailiwick */ |
37 |
|
|
+ if (loop <= 1) |
38 |
|
|
+ return 0 ; |
39 |
|
|
+ else { |
40 |
|
|
+ response[2] &= ~4; |
41 |
|
|
+ goto DONE; /* The administrator has issued contradictory instructions */ |
42 |
|
|
+ } |
43 |
|
|
+ } |
44 |
|
|
control += *control; |
45 |
|
|
control += 1; |
46 |
|
|
} |
47 |
|
|
@@ -172,8 +186,16 @@ |
48 |
|
|
continue; |
49 |
|
|
} |
50 |
|
|
if (!response_rstart(q,type,ttl)) return 0; |
51 |
|
|
- if (byte_equal(type,2,DNS_T_NS) || byte_equal(type,2,DNS_T_CNAME) || byte_equal(type,2,DNS_T_PTR)) { |
52 |
|
|
+ if (byte_equal(type,2,DNS_T_NS) || byte_equal(type,2,DNS_T_PTR)) { |
53 |
|
|
+ if (!doname()) return 0; |
54 |
|
|
+ } |
55 |
|
|
+ else if (byte_equal(type,2,DNS_T_CNAME)) { |
56 |
|
|
if (!doname()) return 0; |
57 |
|
|
+ if (byte_diff(type,2,qtype)) { |
58 |
|
|
+ response_rfinish(RESPONSE_ANSWER); |
59 |
|
|
+ if (!dns_domain_copy(pqname,d1)) return 0 ; |
60 |
|
|
+ goto RESTART ; |
61 |
|
|
+ } |
62 |
|
|
} |
63 |
|
|
else if (byte_equal(type,2,DNS_T_MX)) { |
64 |
|
|
if (!dobytes(2)) return 0; |
65 |
|
|
@@ -275,9 +297,21 @@ |
66 |
|
|
} |
67 |
|
|
} |
68 |
|
|
|
69 |
|
|
+DONE: |
70 |
|
|
return 1; |
71 |
|
|
} |
72 |
|
|
|
73 |
|
|
+static int doit(char *qname,char qtype[2]) |
74 |
|
|
+{ |
75 |
|
|
+ int r ; |
76 |
|
|
+ char * q = 0 ; |
77 |
|
|
+ |
78 |
|
|
+ if (!dns_domain_copy(&q, qname)) return 0 ; |
79 |
|
|
+ r = doit1(&q, qtype) ; |
80 |
|
|
+ dns_domain_free(&q) ; |
81 |
|
|
+ return r ; |
82 |
|
|
+} |
83 |
|
|
+ |
84 |
|
|
int respond(char *q,char qtype[2],char ip[4]) |
85 |
|
|
{ |
86 |
|
|
int fd; |