* [9fans] APE socket bug fix
@ 2000-10-31 11:32 nigel
2000-10-31 16:57 ` Scott Schwartz
0 siblings, 1 reply; 3+ messages in thread
From: nigel @ 2000-10-31 11:32 UTC (permalink / raw)
To: 9fans
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.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [9fans] APE socket bug fix
2000-10-31 11:32 [9fans] APE socket bug fix nigel
@ 2000-10-31 16:57 ` Scott Schwartz
2000-10-31 17:03 ` Scott Schwartz
0 siblings, 1 reply; 3+ messages in thread
From: Scott Schwartz @ 2000-10-31 16:57 UTC (permalink / raw)
To: 9fans
| 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
Actually the addr parameter is supposed to be supplied in network order.
This is one of several related bugs that I fixed for the second edition.
See http://www.cse.psu.edu/~schwartz/www/ape-diffs.bz2
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [9fans] APE socket bug fix
2000-10-31 16:57 ` Scott Schwartz
@ 2000-10-31 17:03 ` Scott Schwartz
0 siblings, 0 replies; 3+ messages in thread
From: Scott Schwartz @ 2000-10-31 17:03 UTC (permalink / raw)
To: 9fans
Arg. Make that http://www.cse.psu.edu/~schwartz/ape-diffs.bz2
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2000-10-31 17:03 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-10-31 11:32 [9fans] APE socket bug fix nigel
2000-10-31 16:57 ` Scott Schwartz
2000-10-31 17:03 ` Scott Schwartz
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).