9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
* [9fans] ape: getsockname: wrong byte order in sin_port
@ 2013-01-08 13:57 Yaroslav
  2013-01-08 21:02 ` erik quanstrom
  0 siblings, 1 reply; 2+ messages in thread
From: Yaroslav @ 2013-01-08 13:57 UTC (permalink / raw)
  To: 9fans

[-- 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 --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [9fans] ape: getsockname: wrong byte order in sin_port
  2013-01-08 13:57 [9fans] ape: getsockname: wrong byte order in sin_port Yaroslav
@ 2013-01-08 21:02 ` erik quanstrom
  0 siblings, 0 replies; 2+ messages in thread
From: erik quanstrom @ 2013-01-08 21:02 UTC (permalink / raw)
  To: 9fans

On Tue Jan  8 08:58:26 EST 2013, yarikos@gmail.com wrote:

> 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.

agree.  patch submitted.  /n/sources/patch/sin_port

- erik



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2013-01-08 21:02 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-01-08 13:57 [9fans] ape: getsockname: wrong byte order in sin_port Yaroslav
2013-01-08 21:02 ` erik quanstrom

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).