From: Philip Homburg Date: Fri, 14 Jul 2006 14:34:00 +0000 (+0000) Subject: Prototypes for send and recv. Fixed send (pass null address) and sendto X-Git-Tag: v3.1.3~246 X-Git-Url: http://zhaoyanbai.com/repos/%22http:/www.isc.org/icons/doc/syslog.3.html?a=commitdiff_plain;h=59830eda3f26c9355bc3b75c69ee4705bf6a4ce1;p=minix.git Prototypes for send and recv. Fixed send (pass null address) and sendto (fail when a null address is passed to a socket that is not connected). --- diff --git a/include/sys/socket.h b/include/sys/socket.h index fb6ddd5de..355160762 100644 --- a/include/sys/socket.h +++ b/include/sys/socket.h @@ -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) ); diff --git a/lib/ip/send.c b/lib/ip/send.c index 27ea0d012..3e12dd90e 100644 --- a/lib/ip/send.c +++ b/lib/ip/send.c @@ -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); } diff --git a/lib/ip/sendto.c b/lib/ip/sendto.c index 1646cf486..6c805ffce 100644 --- a/lib/ip/sendto.c +++ b/lib/ip/sendto.c @@ -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)) {