Convert the port extracted from the SRV record return to network byte
order before assigning it to the port array.
The port in a SRV record is extracted by pulling out the high byte
and low byte and then mathematically combining them, which implicity
converts from network byte order to host byte order. However, the
callers of afsconf_LookupServer expect the port array to be returned
in network byte order since ports are assigned without modification
to the .sin_port field of a struct sockaddr_in. See also the byte
order of the default afsdbPort value.
Reported by Jan Christoph Nordholz (Debian Bug#600228).
Change-Id: I378fe2f769703e43800c185f0934c77dd97b1c7b
Reviewed-on: http://gerrit.openafs.org/2985
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Derrick Brashear <shadow@dementia.org>
Reviewed-by: Jeffrey Altman <jaltman@openafs.org>
Tested-by: Jeffrey Altman <jaltman@openafs.org>
memcpy(&ipaddr, he->h_addr, he->h_length);
cellHostAddrs[server_num] = ipaddr;
ipRanks[server_num] = (p[0] << 8) | p[1];
- ports[server_num] = (p[4] << 8) | p[5];
+ ports[server_num] = htons((p[4] << 8) | p[5]);
/* weight = (p[2] << 8) | p[3]; */
strncpy(cellHostNames[server_num], host,
sizeof(cellHostNames[server_num]));