/[smeserver]/rpms/djbdns/sme9/230-tinydns-data-semantic-error.patch
ViewVC logotype

Contents of /rpms/djbdns/sme9/230-tinydns-data-semantic-error.patch

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.1 - (show annotations) (download)
Wed Jul 12 04:56:18 2017 UTC (7 years, 3 months ago) by unnilennium
Branch: MAIN
CVS Tags: djbdns-1_05-11_el6_sme, djbdns-1_05-9_el6_sme, djbdns-1_05-10_el6_sme, HEAD
* Tue Jul 11 2017 Jean-Philipe Pialasse <tests@pialasse.com> 1.05-9.sme
-- backport SME10 fixes [SME: 10381]
--import patches from openwrt and rename already applied patches
--fix security issues [SME: 10374]
- 020-dnsroots-update.patch: update list of root DNS servers
- 070-dnscache-dpos-tcp-servfail.patch: SERVFAIL rename previous patch dns_transmit-bug.patch
- 210-dnscache-strict-forwardonly.patch: rename previous patch dnscache-strict-forwardonly.patch
- 270-dnscache-sigpipe-fix.patch: SIGPIPE
- 300-bugfix-dnscache-dempsky-poison.patch: CVE-2009-0858
- 310-bugfix-dnscache-merge-outgoing-requests.patch: CVE-2008-4392
- 320-bugfix-dnscache-cache-soa-records.patch: CVE-2008-4392
- 450-dnscache-ghost-domain-CVE-2012-1191.patch: CVE-2012-1191 http://marc.info/?l=djbdns&m=134190748729079&w=2
--bug fixes [SME: 10374]
- 060-dnscache-big-udp-packets.patch: accept and handle longer than 512 bytes UDP packets
- 230-tinydns-data-semantic-error.patch: handle semantic error to avoid publishing false dns records
- 240-tinydns-alias-chain-truncation.patch: rename previous patch tinydns-alias-chain-truncation.patch
--fix issue with short ttl cname like akamaid [SME: 8362]
- 200-dnscache-cname-handling.patch: rename previous patch dnscache-cname-handling.patch
- 330-fix-dnscache-cname-handling.patch: fix dnscache cname for short ttl
- 500-cutom-dnscache-maxloop.patch: set max loop to 200
--needed for previous patches to apply cleanly
- 030-srv-records-and-axfrget.patch: add SRV record type and axfr-get decompose SRC and PTR records (for 230-*.patch)
- 080-dnscache-cache-negatives.patch: rfc2308 ? (for 200-*.patch)
- 090-tinydns-one-second.patch: improve tinydns with 8 or more  concurent connections (for 240-*.patch)
- 120-compiler-temporary-filename.patch: change tmp filename to avoid conflicts (for 230-*.patch)
--not backported from SME10 branch
- 050-tinydns-mmap-leak.patch: report cdb leak

1 --- a/tinydns-data.c
2 +++ b/tinydns-data.c
3 @@ -25,6 +25,14 @@
4
5 #define FATAL "tinydns-data: fatal: "
6
7 +void die_semantic2(const char * s1, const char * s2)
8 +{
9 + strerr_die3x(111,FATAL,s1,s2) ;
10 +}
11 +void die_semantic4(const char * s1, const char * s2,const char * s3, const char * s4)
12 +{
13 + strerr_die5x(111,FATAL,s1,s2,s3,s4) ;
14 +}
15 void die_datatmp(void)
16 {
17 strerr_die2sys(111,FATAL,"unable to create data.cdb.tmp: ");
18 @@ -34,20 +42,39 @@ void nomem(void)
19 strerr_die1sys(111,FATAL);
20 }
21
22 +void ttlparse(stralloc *sa,unsigned long * ttl, unsigned long defttl, const char * ltype)
23 +{
24 + int ttllen ;
25 +
26 + if (sa->len > 0) {
27 + if (!stralloc_0(sa)) nomem();
28 + ttllen = scan_ulong(sa->s,ttl) ;
29 + if (ttllen + 1 != sa->len)
30 + die_semantic4("unparseable TTL in ",ltype," line: ", sa->s) ;
31 + } else
32 + *ttl = defttl;
33 +}
34 +
35 void ttdparse(stralloc *sa,char ttd[8])
36 {
37 unsigned int i;
38 char ch;
39
40 byte_zero(ttd,8);
41 - for (i = 0;(i < 16) && (i < sa->len);++i) {
42 + for (i = 0;i < sa->len;++i) {
43 + if (i >= 16) {
44 + if (!stralloc_0(sa)) nomem() ;
45 + die_semantic2("timestamp is too long: ", sa->s) ;
46 + }
47 ch = sa->s[i];
48 if ((ch >= '0') && (ch <= '9'))
49 ch -= '0';
50 else if ((ch >= 'a') && (ch <= 'f'))
51 ch -= 'a' - 10;
52 - else
53 - ch = 0;
54 + else {
55 + if (!stralloc_0(sa)) nomem() ;
56 + die_semantic2("timestamp contains an invalid character: ", sa->s) ;
57 + }
58 if (!(i & 1)) ch <<= 4;
59 ttd[i >> 1] |= ch;
60 }
61 @@ -55,6 +82,10 @@ void ttdparse(stralloc *sa,char ttd[8])
62
63 void locparse(stralloc *sa,char loc[2])
64 {
65 + if (sa->len > 2) {
66 + if (!stralloc_0(sa)) nomem() ;
67 + die_semantic2("location code longer than two characters: ", sa->s) ;
68 + }
69 loc[0] = (sa->len > 0) ? sa->s[0] : 0;
70 loc[1] = (sa->len > 1) ? sa->s[1] : 0;
71 }
72 @@ -187,6 +218,7 @@ int main()
73 int i;
74 int j;
75 int k;
76 + int iplen ;
77 char ch;
78 unsigned long ttl;
79 char ttd[8];
80 @@ -267,8 +299,7 @@ int main()
81 if (!scan_ulong(f[7].s,&u)) uint32_unpack_big(defaultsoa + 16,&u);
82 uint32_pack_big(soa + 16,u);
83
84 - if (!stralloc_0(&f[8])) nomem();
85 - if (!scan_ulong(f[8].s,&ttl)) ttl = TTL_NEGATIVE;
86 + ttlparse(&f[8],&ttl,TTL_NEGATIVE,"Z");
87 ttdparse(&f[9],ttd);
88 locparse(&f[10],loc);
89
90 @@ -283,8 +314,7 @@ int main()
91
92 case '.': case '&':
93 if (!dns_domain_fromdot(&d1,f[0].s,f[0].len)) nomem();
94 - if (!stralloc_0(&f[3])) nomem();
95 - if (!scan_ulong(f[3].s,&ttl)) ttl = TTL_NS;
96 + ttlparse(&f[3],&ttl,TTL_NS,". or &");
97 ttdparse(&f[4],ttd);
98 locparse(&f[5],loc);
99
100 @@ -309,24 +339,26 @@ int main()
101 rr_addname(d2);
102 rr_finish(d1);
103
104 - if (ip4_scan(f[1].s,ip)) {
105 + iplen = ip4_scan(f[1].s,ip) ;
106 + if (iplen != 0 && iplen + 1 == f[1].len) {
107 rr_start(DNS_T_A,ttl,ttd,loc);
108 rr_add(ip,4);
109 rr_finish(d2);
110 - }
111 + } else if (f[1].len > 1)
112 + die_semantic4("unparseable IP address in ","& or ."," line: ", f[1].s) ;
113
114 break;
115
116 case '+': case '=':
117 if (!dns_domain_fromdot(&d1,f[0].s,f[0].len)) nomem();
118 - if (!stralloc_0(&f[2])) nomem();
119 - if (!scan_ulong(f[2].s,&ttl)) ttl = TTL_POSITIVE;
120 + ttlparse(&f[2],&ttl,TTL_POSITIVE,"+ or =");
121 ttdparse(&f[3],ttd);
122 locparse(&f[4],loc);
123
124 if (!stralloc_0(&f[1])) nomem();
125
126 - if (ip4_scan(f[1].s,ip)) {
127 + iplen = ip4_scan(f[1].s,ip) ;
128 + if (iplen != 0 && iplen + 1 == f[1].len) {
129 rr_start(DNS_T_A,ttl,ttd,loc);
130 rr_add(ip,4);
131 rr_finish(d1);
132 @@ -337,13 +369,15 @@ int main()
133 rr_addname(d1);
134 rr_finish(dptr);
135 }
136 - }
137 + } else if (f[1].len > 1)
138 + die_semantic4("unparseable IP address in ","+ or ="," line: ", f[1].s) ;
139 + else
140 + die_semantic4("missing IP address in ","+ or ="," line: ", f[1].s) ;
141 break;
142
143 case '@':
144 if (!dns_domain_fromdot(&d1,f[0].s,f[0].len)) nomem();
145 - if (!stralloc_0(&f[4])) nomem();
146 - if (!scan_ulong(f[4].s,&ttl)) ttl = TTL_POSITIVE;
147 + ttlparse(&f[4],&ttl,TTL_POSITIVE,"@");
148 ttdparse(&f[5],ttd);
149 locparse(&f[6],loc);
150
151 @@ -401,18 +435,19 @@ int main()
152 rr_addname(d2);
153 rr_finish(d1);
154
155 - if (ip4_scan(f[1].s,ip)) {
156 + iplen = ip4_scan(f[1].s,ip) ;
157 + if (iplen != 0 && iplen + 1 == f[1].len) {
158 rr_start(DNS_T_A,ttl,ttd,loc);
159 rr_add(ip,4);
160 rr_finish(d2);
161 - }
162 + } else if (f[1].len > 1)
163 + die_semantic4("unparseable IP address in ","@"," line: ", f[1].s) ;
164 break;
165
166 case '^': case 'C':
167 if (!dns_domain_fromdot(&d1,f[0].s,f[0].len)) nomem();
168 if (!dns_domain_fromdot(&d2,f[1].s,f[1].len)) nomem();
169 - if (!stralloc_0(&f[2])) nomem();
170 - if (!scan_ulong(f[2].s,&ttl)) ttl = TTL_POSITIVE;
171 + ttlparse(&f[2],&ttl,TTL_POSITIVE,"^ or C");
172 ttdparse(&f[3],ttd);
173 locparse(&f[4],loc);
174
175 @@ -426,8 +461,7 @@ int main()
176
177 case '\'':
178 if (!dns_domain_fromdot(&d1,f[0].s,f[0].len)) nomem();
179 - if (!stralloc_0(&f[2])) nomem();
180 - if (!scan_ulong(f[2].s,&ttl)) ttl = TTL_POSITIVE;
181 + ttlparse(&f[2],&ttl,TTL_POSITIVE,"\'");
182 ttdparse(&f[3],ttd);
183 locparse(&f[4],loc);
184
185 @@ -449,8 +483,7 @@ int main()
186
187 case ':':
188 if (!dns_domain_fromdot(&d1,f[0].s,f[0].len)) nomem();
189 - if (!stralloc_0(&f[3])) nomem();
190 - if (!scan_ulong(f[3].s,&ttl)) ttl = TTL_POSITIVE;
191 + ttlparse(&f[3],&ttl,TTL_POSITIVE,":");
192 ttdparse(&f[4],ttd);
193 locparse(&f[5],loc);
194

admin@koozali.org
ViewVC Help
Powered by ViewVC 1.2.1 RSS 2.0 feed