As svcfd_create(3) said, it can: Create a service on top of any open file descriptor. But getsockname and getpeername in svc_fd_create assume that fd should be a connected socket. This patch will leave xp_raddr and xp_laddr uninitialized if fd is not a connected socket. Signed-off-by: Chen Hanxiao <chenhx.fnst@xxxxxxxxxxx> --- src/svc_vc.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/svc_vc.c b/src/svc_vc.c index 3dc8a75..438cbc5 100644 --- a/src/svc_vc.c +++ b/src/svc_vc.c @@ -59,6 +59,7 @@ #include <rpc/rpc.h> #include "rpc_com.h" +#include "debug.h" #include <getpeereid.h> @@ -232,6 +233,12 @@ svc_fd_create(fd, sendsize, recvsize) slen = sizeof (struct sockaddr_storage); if (getsockname(fd, (struct sockaddr *)(void *)&ss, &slen) < 0) { + if (errno == ENOTSOCK) { + if (libtirpc_debug_level > 3) { + LIBTIRPC_DEBUG(4, ("svc_fd_create: ENOTSOCK, return directly")); + } + return ret; + } warnx("svc_fd_create: could not retrieve local addr"); goto freedata; } -- 2.43.1