9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
From: Yaroslav <yarikos@gmail.com>
To: 9fans@9fans.net
Subject: [9fans] ape: getsockname: wrong byte order in sin_port
Date: Tue,  8 Jan 2013 15:57:24 +0200	[thread overview]
Message-ID: <CAG3N4d8Urjyhnw-08BvrER4a90J3+14EU+HrErtxU3kaKNp-NA@mail.gmail.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 436 bytes --]

APE's getsockname() returns port with bytes swapped (on 386).
Fix:

/n/dump/2013/0108/sys/src/ape/lib/bsd/_sock_ingetaddr.c:35,41 -
/sys/src/ape/lib/bsd/_sock_ingetaddr.c:35,41
  if(p){
  *p++ = 0;
  ip->sin_family = AF_INET;
- ip->sin_port = atoi(p);
+ ip->sin_port = htons(atoi(p));
  ip->sin_addr.s_addr = inet_addr(name);
  if(alen)
  *alen = sizeof(struct sockaddr_in);

Python needs to be relinked.
--
- Yaroslav

[-- Attachment #2: Type: text/html, Size: 1055 bytes --]

             reply	other threads:[~2013-01-08 13:57 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-01-08 13:57 Yaroslav [this message]
2013-01-08 21:02 ` erik quanstrom

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=CAG3N4d8Urjyhnw-08BvrER4a90J3+14EU+HrErtxU3kaKNp-NA@mail.gmail.com \
    --to=yarikos@gmail.com \
    --cc=9fans@9fans.net \
    /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).