diff --git a/ChangeLog b/ChangeLog index 69d8872b..133ccbdb 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +* 201?-??-??: Version 1.?.? + * Bugfix #359: edns_client_subnet_private should set family + Thanks Daniel Areiza + * 2017-11-11: Version 1.2.1 * Handle more I/O error cases. Also, when an I/O error does occur, never stop listening (with servers), and diff --git a/src/stub.c b/src/stub.c index 10745928..d8da9a9c 100644 --- a/src/stub.c +++ b/src/stub.c @@ -151,15 +151,19 @@ calc_new_cookie(getdns_upstream *upstream, uint8_t *cookie) static getdns_return_t attach_edns_client_subnet_private(getdns_network_req *req) { - /* see - * https://tools.ietf.org/html/draft-ietf-dnsop-edns-client-subnet-04#section-6 */ - /* all-zeros is a request to not leak the data further: */ - /* "\x00\x00" FAMILY: 0 (because no address) */ - /* "\x00" SOURCE PREFIX-LENGTH: 0 */ - /* "\x00"; SCOPE PREFIX-LENGTH: 0 */ - return _getdns_network_req_add_upstream_option(req, - GLDNS_EDNS_CLIENT_SUBNET, - 4, NULL); + /* see https://tools.ietf.org/html/rfc7871#section-7.1.2 + * all-zeros is a request to not leak the data further: + * A two byte FAMILY field is a SHOULD even when SOURCE + * and SCOPE are 0. + * "\x00\x02" FAMILY: 2 for IPv6 upstreams in network byte order, or + * "\x00\x01" FAMILY: 1 for IPv4 upstreams in network byte order, then: + * "\x00" SOURCE PREFIX-LENGTH: 0 + * "\x00"; SCOPE PREFIX-LENGTH: 0 + */ + return _getdns_network_req_add_upstream_option( + req, GLDNS_EDNS_CLIENT_SUBNET, 4, + ( req->upstream->addr.ss_family == AF_INET6 + ? "\x00\x02\x00\x00" : "\x00\x01\x00\x00" )); } static getdns_return_t