From 28f65219b409136e0bc66358f5711b32277baad2 Mon Sep 17 00:00:00 2001 From: Russ Allbery Date: Thu, 14 Oct 2010 13:41:45 -0700 Subject: [PATCH] Return SRV record ports in network byte order 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). Reviewed-on: http://gerrit.openafs.org/2985 Tested-by: BuildBot Reviewed-by: Derrick Brashear Reviewed-by: Jeffrey Altman Tested-by: Jeffrey Altman (cherry picked from commit ffe445483a07c751202a1ef06136f70402ec895d) Change-Id: I918ed4acdcfecbe1f879746d80b501714f1e775f Reviewed-on: http://gerrit.openafs.org/3107 Tested-by: Derrick Brashear --- src/auth/cellconfig.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/auth/cellconfig.c b/src/auth/cellconfig.c index 011e6bce4..bc1b3efc8 100644 --- a/src/auth/cellconfig.c +++ b/src/auth/cellconfig.c @@ -1162,7 +1162,7 @@ afsconf_LookupServer(const char *service, const char *protocol, 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])); -- 2.39.5