Fix non-UDP 'from' in recvfrom() (XCC)
authorBarret Rhoden <brho@cs.berkeley.edu>
Mon, 19 Sep 2016 15:30:39 +0000 (11:30 -0400)
committerBarret Rhoden <brho@cs.berkeley.edu>
Mon, 19 Sep 2016 15:30:39 +0000 (11:30 -0400)
getsockname() gets *our* name, not the peer's name.  We wanted the peer's
name.

Rebuild glibc.

Signed-off-by: Barret Rhoden <brho@cs.berkeley.edu>
tools/compilers/gcc-glibc/glibc-2.19-akaros/sysdeps/akaros/recvfrom.c

index 0bf8a50..3e449bd 100644 (file)
@@ -66,12 +66,11 @@ ssize_t __recvfrom_iov(int fd, const struct iovec *iov, int iovcnt,
                errno = EOPNOTSUPP;
                return -1;
        }
-       if (from.__sockaddr__ && getsockname(fd, from, fromlen) < 0)
-               return -1;
        if (udp_sock_get_rock(fd))
                return __recvfrom_udp(fd, iov, iovcnt, flags, from, fromlen);
-       else
-               return readv(fd, iov, iovcnt);
+       if (from.__sockaddr__ && getpeername(fd, from, fromlen) < 0)
+               return -1;
+       return readv(fd, iov, iovcnt);
 }
 
 /* Read N bytes into BUF through socket FD from peer at address FROM (which is