]> Zhao Yanbai Git Server - minix.git/commitdiff
Prototypes for send and recv. Fixed send (pass null address) and sendto
authorPhilip Homburg <philip@cs.vu.nl>
Fri, 14 Jul 2006 14:34:00 +0000 (14:34 +0000)
committerPhilip Homburg <philip@cs.vu.nl>
Fri, 14 Jul 2006 14:34:00 +0000 (14:34 +0000)
(fail when a null address is passed to a socket that is not connected).

include/sys/socket.h
lib/ip/send.c
lib/ip/sendto.c

index fb6ddd5dea4141dc38d12e229efd9116606aa01a..3551607624c67eaeedebbaa8884943e5bc07381e 100644 (file)
@@ -65,9 +65,13 @@ _PROTOTYPE( int setsockopt,(int _socket, int _level, int _option_name,
 _PROTOTYPE( int getsockopt, (int _socket, int _level, int _option_name,
         void *_RESTRICT _option_value, socklen_t *_RESTRICT _option_len));
 _PROTOTYPE( int listen, (int _socket, int _backlog)                    );
+_PROTOTYPE( ssize_t recv, (int _socket, void *_buffer, size_t _length,
+                                                       int _flags)     );
 _PROTOTYPE( ssize_t recvfrom, (int _socket, void *_RESTRICT _buffer,
        size_t _length, int _flags, struct sockaddr *_RESTRICT _address,
                                socklen_t *_RESTRICT _address_len)      );
+_PROTOTYPE( ssize_t send, (int _socket, const void *_buffer,
+                                       size_t _length, int _flags)     );
 _PROTOTYPE( ssize_t sendto, (int _socket, const void *_message,
        size_t _length, int _flags, const struct sockaddr *_dest_addr,
                                                socklen_t _dest_len)    );
index 27ea0d012e4b04fc3289a14e07178808f054cc6e..3e12dd90ec399bb7a0c1c58d467a5a217c3d13a2 100644 (file)
@@ -3,9 +3,6 @@
 
 ssize_t send(int socket, const void *buffer, size_t length, int flags)
 {
-       struct sockaddr sa;
-
-       sa.sa_family= AF_UNSPEC;
-       return sendto(socket, buffer, length, flags, &sa, sizeof(sa));
+       return sendto(socket, buffer, length, flags, NULL, 0);
 }
 
index 1646cf4868c1f374d6bca031c9c2f2f7faab2c93..6c805ffce97d243f87297fe494f764bbd0d542b1 100644 (file)
@@ -68,6 +68,12 @@ static ssize_t _udp_sendto(int socket, const void *message, size_t length,
        if ((udpoptp->nwuo_flags & NWUO_RP_ANY) ||
                (udpoptp->nwuo_flags & NWUO_RA_ANY))
        {
+               if (!dest_addr)
+               {
+                       errno= ENOTCONN;
+                       return -1;
+               }
+
                /* Check destination address */
                if (dest_len < sizeof(*sinp))
                {