Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TS-4688 handle DNS compression labels in SRV responses #812

Merged
merged 1 commit into from Jul 21, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
22 changes: 11 additions & 11 deletions iocore/dns/DNS.cc
Expand Up @@ -1514,24 +1514,24 @@ dns_process(DNSHandler *handler, HostEnt *buf, int len)
cp += dn_skipname(cp, eom);
here = cp; /* hack */
SRV *srv = &buf->srv_hosts.hosts[num_srv];
int r = ink_ns_name_ntop(srv_off + SRV_SERVER, srv->host, MAXDNAME);
if (r <= 0) {
/* FIXME: is this really an error? or just a continue; */

// expand the name
n = ink_dn_expand((u_char *)h, eom, srv_off + SRV_SERVER, (u_char *)srv->host, MAXDNAME);
if (n < 0) {
++error;
goto Lerror;
break;
}
Debug("dns_srv", "Discovered SRV record [from NS lookup] with cost:%d weight:%d port:%d with host:%s",
ink_get16(srv_off + SRV_COST), ink_get16(srv_off + SRV_WEIGHT), ink_get16(srv_off + SRV_PORT), srv->host);

srv->port = ink_get16(srv_off + SRV_PORT);
srv->priority = ink_get16(srv_off + SRV_COST);
srv->weight = ink_get16(srv_off + SRV_WEIGHT);
srv->host_len = r;
srv->host[r - 1] = '\0';
srv->key = makeHostHash(srv->host);
srv->port = ink_get16(srv_off + SRV_PORT);
srv->priority = ink_get16(srv_off + SRV_COST);
srv->weight = ink_get16(srv_off + SRV_WEIGHT);
srv->host_len = ::strlen(srv->host) + 1;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

n doesn't have the value you want here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sadly no, n is the length of the compressed string, not the expanded string-- meaning I have to calculate the len of the expanded string.

srv->key = makeHostHash(srv->host);

if (srv->host[0] != '\0')
buf->srv_hosts.srv_hosts_length += r;
buf->srv_hosts.srv_hosts_length += srv->host_len;
else
continue;
++num_srv;
Expand Down