Alle lunedì 11 ottobre 2010, Samuel Thibault ha scritto:
> Pino Toscano, le Sun 10 Oct 2010 23:46:10 +0200, a écrit :
> > make_sockaddr_port() calls the getname function of the sock-ops of
> > the current sock struct, which can be one of
> > - linux-src/net/ipv6/af_inet6.c:inet6_getname()
> > - linux-src/net/ipv4/af_inet.c:inet_getname()
> > - linux-src/net/core/sock.c:sock_no_getname()
> > all of them return negative errno values, which
> > make_sockaddr_port() return straight those as well.
> > Not totally sure about where to fix, i.e. a "return -err" in
> > make_sockaddr_port() after the getname call, or in all the callers
> > of make_sockaddr_port().
> 
> Hurd functions don't usually return -errnos, only Linux-inherited
> ones do.

I see; attached the commit with the fix.

-- 
Pino Toscano
From 7aa424fc1cdfeb487a1bfc2e4dfeaac61df51185 Mon Sep 17 00:00:00 2001
From: Pino Toscano <toscano.p...@tiscali.it>
Date: Mon, 11 Oct 2010 17:07:53 +0200
Subject: [PATCH] Fix return value on `getname' errors.

This fixes the errno return value for getpeername() calls on not connected
sockets.

* pfinet/misc.c (make_sockaddr_port): The return value of the `getname' call
comes from the Linux code, so it is a negative value, in case of error. Then
make it a positive number to get a valid errno value.
---
 pfinet/misc.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/pfinet/misc.c b/pfinet/misc.c
index 56611da..08b19e9 100644
--- a/pfinet/misc.c
+++ b/pfinet/misc.c
@@ -42,7 +42,7 @@ make_sockaddr_port (struct socket *sock,
 
   err = (*sock->ops->getname) (sock, &buf.sa, &buflen, peer);
   if (err)
-    return err;
+    return -err;
 
   err = ports_create_port (addrport_class, pfinet_bucket,
 			   (offsetof (struct sock_addr, address)
-- 
1.7.1

Attachment: signature.asc
Description: This is a digitally signed message part.

Reply via email to