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).
This commit is contained in:
parent
371ac29c9f
commit
59830eda3f
3 changed files with 11 additions and 4 deletions
|
@ -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) );
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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))
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue