From mboxrd@z Thu Jan 1 00:00:00 1970 From: nigel@9fs.org To: 9fans@cse.psu.edu MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit Message-Id: Subject: [9fans] APE socket bug fix Date: Tue, 31 Oct 2000 11:32:22 +0000 Topicbox-Message-UUID: 1ea4629a-eac9-11e9-9e20-41e7f4b1d025 gethostbyaddr() has a sign extension bug which causes it to mess up the building of the 32 bit address to put in in_addr. Additionally, htonl() is required to convert to network byte order. So struct hostent* gethostbyaddr(char *addr, int len, int type) { struct in_addr x; if(type != AF_INET){ h_errno = NO_RECOVERY; return 0; } x.s_addr = (addr[0]<<24)|(addr[1]<<16)|(addr[2]<<8)|addr[3]; return gethostbyname(inet_ntoa(x)); } probably ought to be struct hostent* gethostbyaddr(char *addr, int len, int type) { struct in_addr x; unsigned char *uaddr = (unsigned char *)addr; if(type != AF_INET){ h_errno = NO_RECOVERY; return 0; } x.s_addr = htonl((uaddr[0]<<24)|(uaddr[1]<<16)|(uaddr[2]<<8)|uaddr[3]); return gethostbyname(inet_ntoa(x)); } or words to that effect.