mirror of
https://github.com/yarrick/iodine.git
synced 2025-04-11 04:50:55 +00:00
fix #38: responds to NS/A with IP from -n argument
As described in issue #38, DNS type NS requests to iodined got responses with additional IP that was incorrect (always 2.0.0.0) if the -n argument switch was used to specify a custom IP address. The same applied to A requests (for ns.topdomain); the IP was always 2.0.0.0 because of wrong memory copying. This commit fix solves this issue by correctly memory copying ns_ip to query destination (&q->destination).
This commit is contained in:
parent
d09c3e4f0b
commit
a2d1ffa150
1 changed files with 6 additions and 4 deletions
|
@ -1548,8 +1548,9 @@ handle_ns_request(int dns_fd, struct query *q)
|
||||||
if (ns_ip != INADDR_ANY) {
|
if (ns_ip != INADDR_ANY) {
|
||||||
/* If ns_ip set, overwrite destination addr with it.
|
/* If ns_ip set, overwrite destination addr with it.
|
||||||
* Destination addr will be sent as additional record (A, IN) */
|
* Destination addr will be sent as additional record (A, IN) */
|
||||||
struct sockaddr_in *addr = (struct sockaddr_in *) &q->destination;
|
struct sockaddr_in *addr = (struct sockaddr_in *) &q->destination; /* probably not needed */
|
||||||
memcpy(&addr->sin_addr, &ns_ip, sizeof(ns_ip));
|
memcpy(&q->destination, &ns_ip, sizeof(ns_ip));
|
||||||
|
memcpy(&addr->sin_addr, &ns_ip, sizeof(ns_ip)); /* probably not needed */
|
||||||
}
|
}
|
||||||
|
|
||||||
len = dns_encode_ns_response(buf, sizeof(buf), q, topdomain);
|
len = dns_encode_ns_response(buf, sizeof(buf), q, topdomain);
|
||||||
|
@ -1582,8 +1583,9 @@ handle_a_request(int dns_fd, struct query *q, int fakeip)
|
||||||
} else if (ns_ip != INADDR_ANY) {
|
} else if (ns_ip != INADDR_ANY) {
|
||||||
/* If ns_ip set, overwrite destination addr with it.
|
/* If ns_ip set, overwrite destination addr with it.
|
||||||
* Destination addr will be sent as additional record (A, IN) */
|
* Destination addr will be sent as additional record (A, IN) */
|
||||||
struct sockaddr_in *addr = (struct sockaddr_in *) &q->destination;
|
struct sockaddr_in *addr = (struct sockaddr_in *) &q->destination; /* probably not needed */
|
||||||
memcpy(&addr->sin_addr, &ns_ip, sizeof(ns_ip));
|
memcpy(&q->destination, &ns_ip, sizeof(ns_ip));
|
||||||
|
memcpy(&addr->sin_addr, &ns_ip, sizeof(ns_ip)); /* probably not needed */
|
||||||
}
|
}
|
||||||
|
|
||||||
len = dns_encode_a_response(buf, sizeof(buf), q);
|
len = dns_encode_a_response(buf, sizeof(buf), q);
|
||||||
|
|
Loading…
Add table
Reference in a new issue