From: nigel@9fs.org
To: 9fans@cse.psu.edu
Subject: [9fans] APE socket bug fix
Date: Tue, 31 Oct 2000 11:32:22 +0000 [thread overview]
Message-ID: <E13qZeR-000Afr-0U@anchor-post-30.mail.demon.net> (raw)
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.
next reply other threads:[~2000-10-31 11:32 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2000-10-31 11:32 nigel [this message]
2000-10-31 16:57 ` Scott Schwartz
2000-10-31 17:03 ` Scott Schwartz
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=E13qZeR-000Afr-0U@anchor-post-30.mail.demon.net \
--to=nigel@9fs.org \
--cc=9fans@cse.psu.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).