NetBSD-Bugs archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
lib/45564: 2nd socket created by socketpair(2) is not connected to 1st socket.
>Number: 45564
>Category: lib
>Synopsis: 2nd socket created by socketpair(2) is not connected to 1st
>socket.
>Confidential: no
>Severity: non-critical
>Priority: medium
>Responsible: lib-bug-people
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Thu Nov 03 18:05:00 +0000 2011
>Originator: Yui NARUSE
>Release: NetBSD 5.99.56 i386
>Organization:
>Environment:
NetBSD nbsd.rubyci.org 5.99.56 NetBSD 5.99.56 (GENERIC) #1: Tue Nov 1 15:09:32
JST 2011
naruse%nbsd.rubyci.org@localhost:/usr/obj/sys/arch/i386/compile/GENERIC i386
>Description:
socketpair(2) should return two sockets connected with each other.
But current NetBSD's one returns invalid pair.
2nd pair is not connected to 1st one.
>How-To-Repeat:
Run following program.
The result will be:
res:-1 errno:57
getpeername: Socket is not connected
#include <stdio.h>
#include <errno.h>
#include <sys/socket.h>
#include <sys/un.h>
int main(void) {
int sv[2];
int res = socketpair(AF_UNIX, SOCK_DGRAM|SOCK_CLOEXEC, 0, sv);
if (res != 0) {
fprintf(stderr, "res:%d errno:%d\n",res,errno);
perror("socketpair");
return 1;
}
struct sockaddr_un addr;
socklen_t len = (socklen_t)sizeof(addr);
res = getpeername(sv[1], (struct sockaddr*)&addr, &len);
if (res != 0) {
fprintf(stderr, "res:%d errno:%d\n",res,errno);
perror("getpeername");
return 1;
}
return 0;
}
>Fix:
Home |
Main Index |
Thread Index |
Old Index