diff options
author | Philipp Tölke <toelke@in.tum.de> | 2011-10-26 12:44:01 +0000 |
---|---|---|
committer | Philipp Tölke <toelke@in.tum.de> | 2011-10-26 12:44:01 +0000 |
commit | 9015eb2c40ca51f1adfe24d17f169ce19cfab4c6 (patch) | |
tree | 346dacea1e0ca76f6ad13b5c5a5573282d9bd05e | |
parent | e02328ef9988444880c36d108aed7ab531c9e3b2 (diff) | |
download | gnunet-9015eb2c40ca51f1adfe24d17f169ce19cfab4c6.tar.gz gnunet-9015eb2c40ca51f1adfe24d17f169ce19cfab4c6.zip |
bugs
-rw-r--r-- | src/vpn/gnunet-dns-parser.c | 25 | ||||
-rw-r--r-- | src/vpn/gnunet-service-dns.c | 13 |
2 files changed, 23 insertions, 15 deletions
diff --git a/src/vpn/gnunet-dns-parser.c b/src/vpn/gnunet-dns-parser.c index 31b0af1a7..e3b03fefd 100644 --- a/src/vpn/gnunet-dns-parser.c +++ b/src/vpn/gnunet-dns-parser.c | |||
@@ -154,6 +154,7 @@ unparse_dns_name(char* dest, char* src, size_t len) | |||
154 | cnt = 0; | 154 | cnt = 0; |
155 | b = dest; | 155 | b = dest; |
156 | dest++; | 156 | dest++; |
157 | src++; | ||
157 | } | 158 | } |
158 | *b = 0; | 159 | *b = 0; |
159 | } | 160 | } |
@@ -163,36 +164,36 @@ unparse_dns_packet (struct dns_pkt_parsed* ppkt) | |||
163 | { | 164 | { |
164 | size_t size = sizeof(struct dns_pkt) - 1; | 165 | size_t size = sizeof(struct dns_pkt) - 1; |
165 | int i; | 166 | int i; |
166 | for (i = 0; i < ppkt->s.qdcount; i++) | 167 | for (i = 0; i < ntohs(ppkt->s.qdcount); i++) |
167 | size += ppkt->queries[i]->namelen + 1; | 168 | size += ppkt->queries[i]->namelen + 1; |
168 | 169 | ||
169 | for (i = 0; i < ppkt->s.ancount; i++) | 170 | for (i = 0; i < ntohs(ppkt->s.ancount); i++) |
170 | { | 171 | { |
171 | size += ppkt->answers[i]->namelen + 1; | 172 | size += ppkt->answers[i]->namelen + 1; |
172 | size += ppkt->answers[i]->data_len; | 173 | size += ppkt->answers[i]->data_len; |
173 | } | 174 | } |
174 | for (i = 0; i < ppkt->s.nscount; i++) | 175 | for (i = 0; i < ntohs(ppkt->s.nscount); i++) |
175 | { | 176 | { |
176 | size += ppkt->nameservers[i]->namelen + 1; | 177 | size += ppkt->nameservers[i]->namelen + 1; |
177 | size += ppkt->nameservers[i]->data_len; | 178 | size += ppkt->nameservers[i]->data_len; |
178 | } | 179 | } |
179 | for (i = 0; i < ppkt->s.arcount; i++) | 180 | for (i = 0; i < ntohs(ppkt->s.arcount); i++) |
180 | { | 181 | { |
181 | size += ppkt->additional[i]->namelen + 1; | 182 | size += ppkt->additional[i]->namelen + 1; |
182 | size += ppkt->additional[i]->data_len; | 183 | size += ppkt->additional[i]->data_len; |
183 | } | 184 | } |
184 | 185 | ||
185 | size += 4*ppkt->s.qdcount + 10*( | 186 | size += 4*ntohs(ppkt->s.qdcount) + 10*( |
186 | ppkt->s.ancount+ | 187 | ntohs(ppkt->s.ancount)+ |
187 | ppkt->s.arcount+ | 188 | ntohs(ppkt->s.arcount)+ |
188 | ppkt->s.nscount); | 189 | ntohs(ppkt->s.nscount)); |
189 | 190 | ||
190 | struct dns_pkt *pkt = GNUNET_malloc(size); | 191 | struct dns_pkt *pkt = GNUNET_malloc(size); |
191 | char *pkt_c = (char*)pkt; | 192 | char *pkt_c = (char*)pkt; |
192 | memcpy(&pkt->s, &ppkt->s, sizeof ppkt->s); | 193 | memcpy(&pkt->s, &ppkt->s, sizeof ppkt->s); |
193 | size_t idx = sizeof ppkt->s; | 194 | size_t idx = sizeof ppkt->s; |
194 | 195 | ||
195 | for (i = 0; i < ppkt->s.qdcount; i++) | 196 | for (i = 0; i < ntohs(ppkt->s.qdcount); i++) |
196 | { | 197 | { |
197 | unparse_dns_name(&pkt_c[idx], ppkt->queries[i]->name, ppkt->queries[i]->namelen); | 198 | unparse_dns_name(&pkt_c[idx], ppkt->queries[i]->name, ppkt->queries[i]->namelen); |
198 | idx += ppkt->queries[i]->namelen; | 199 | idx += ppkt->queries[i]->namelen; |
@@ -202,7 +203,7 @@ unparse_dns_packet (struct dns_pkt_parsed* ppkt) | |||
202 | idx += sizeof(struct dns_query_line); | 203 | idx += sizeof(struct dns_query_line); |
203 | } | 204 | } |
204 | 205 | ||
205 | for (i = 0; i < ppkt->s.ancount; i++) | 206 | for (i = 0; i < ntohs(ppkt->s.ancount); i++) |
206 | { | 207 | { |
207 | unparse_dns_name(&pkt_c[idx], ppkt->answers[i]->name, ppkt->answers[i]->namelen); | 208 | unparse_dns_name(&pkt_c[idx], ppkt->answers[i]->name, ppkt->answers[i]->namelen); |
208 | idx += ppkt->answers[i]->namelen; | 209 | idx += ppkt->answers[i]->namelen; |
@@ -216,7 +217,7 @@ unparse_dns_packet (struct dns_pkt_parsed* ppkt) | |||
216 | idx += ppkt->answers[i]->data_len; | 217 | idx += ppkt->answers[i]->data_len; |
217 | } | 218 | } |
218 | 219 | ||
219 | for (i = 0; i < ppkt->s.nscount; i++) | 220 | for (i = 0; i < ntohs(ppkt->s.nscount); i++) |
220 | { | 221 | { |
221 | unparse_dns_name(&pkt_c[idx], ppkt->nameservers[i]->name, ppkt->nameservers[i]->namelen); | 222 | unparse_dns_name(&pkt_c[idx], ppkt->nameservers[i]->name, ppkt->nameservers[i]->namelen); |
222 | idx += ppkt->nameservers[i]->namelen; | 223 | idx += ppkt->nameservers[i]->namelen; |
@@ -230,7 +231,7 @@ unparse_dns_packet (struct dns_pkt_parsed* ppkt) | |||
230 | idx += ppkt->nameservers[i]->data_len; | 231 | idx += ppkt->nameservers[i]->data_len; |
231 | } | 232 | } |
232 | 233 | ||
233 | for (i = 0; i < ppkt->s.arcount; i++) | 234 | for (i = 0; i < ntohs(ppkt->s.arcount); i++) |
234 | { | 235 | { |
235 | unparse_dns_name(&pkt_c[idx], ppkt->additional[i]->name, ppkt->additional[i]->namelen); | 236 | unparse_dns_name(&pkt_c[idx], ppkt->additional[i]->name, ppkt->additional[i]->namelen); |
236 | idx += ppkt->additional[i]->namelen; | 237 | idx += ppkt->additional[i]->namelen; |
diff --git a/src/vpn/gnunet-service-dns.c b/src/vpn/gnunet-service-dns.c index 2f413c763..00d93ab24 100644 --- a/src/vpn/gnunet-service-dns.c +++ b/src/vpn/gnunet-service-dns.c | |||
@@ -499,9 +499,12 @@ receive_mesh_answer (void *cls | |||
499 | int i = 0; | 499 | int i = 0; |
500 | 500 | ||
501 | while (i < ntohs(pdns->s.ancount) && | 501 | while (i < ntohs(pdns->s.ancount) && |
502 | pdns->answers[i]->type != 28 && | 502 | ntohs(pdns->answers[i]->type) != 28 && |
503 | pdns->answers[i]->type != 1) | 503 | ntohs(pdns->answers[i]->type) != 1) |
504 | { | ||
505 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Answer contains %d.\n", ntohs(pdns->answers[i]->type)); | ||
504 | i++; | 506 | i++; |
507 | } | ||
505 | 508 | ||
506 | if (i >= ntohs (pdns->s.ancount)) | 509 | if (i >= ntohs (pdns->s.ancount)) |
507 | { | 510 | { |
@@ -1005,14 +1008,18 @@ receive_query (void *cls | |||
1005 | cls_->hdr.size - sizeof (struct GNUNET_MessageHeader)); | 1008 | cls_->hdr.size - sizeof (struct GNUNET_MessageHeader)); |
1006 | GNUNET_SCHEDULER_add_now (send_mesh_query, cls_); | 1009 | GNUNET_SCHEDULER_add_now (send_mesh_query, cls_); |
1007 | 1010 | ||
1008 | if (pdns->s.qdcount == 1) | 1011 | if (ntohs(pdns->s.qdcount) == 1) |
1009 | { | 1012 | { |
1010 | if (ntohs(pdns->queries[0]->qtype) == 1) | 1013 | if (ntohs(pdns->queries[0]->qtype) == 1) |
1011 | pdns->queries[0]->qtype = htons(28); | 1014 | pdns->queries[0]->qtype = htons(28); |
1012 | else if (ntohs(pdns->queries[0]->qtype) == 28) | 1015 | else if (ntohs(pdns->queries[0]->qtype) == 28) |
1013 | pdns->queries[0]->qtype = htons(1); | 1016 | pdns->queries[0]->qtype = htons(1); |
1014 | else | 1017 | else |
1018 | { | ||
1019 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "not sending second packet\n"); | ||
1015 | goto outfree; | 1020 | goto outfree; |
1021 | } | ||
1022 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "sending second packet\n"); | ||
1016 | struct dns_pkt *rdns = unparse_dns_packet (pdns); | 1023 | struct dns_pkt *rdns = unparse_dns_packet (pdns); |
1017 | size_t size = | 1024 | size_t size = |
1018 | sizeof (struct GNUNET_MESH_Tunnel *) + | 1025 | sizeof (struct GNUNET_MESH_Tunnel *) + |