Skip to content

Commit

Permalink
Merge pull request RIOT-OS#7174 from miri64/gnrc_sock/fix/return-EINV…
Browse files Browse the repository at this point in the history
…AL-for-inval-sock

sock: specify invalid parameter error
  • Loading branch information
kaspar030 authored Nov 2, 2017
2 parents 060d49f + ce0d81c commit c02ee08
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
2 changes: 2 additions & 0 deletions sys/include/net/sock/ip.h
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,8 @@ int sock_ip_get_remote(sock_ip_t *sock, sock_ip_ep_t *ep);
* @return 0, if no received data is available, but everything is in order.
* @return -EADDRNOTAVAIL, if local of @p sock is not given.
* @return -EAGAIN, if @p timeout is `0` and no data is available.
* @return -EINVAL, if @p remote is invalid or @p sock is not properly
* initialized (or closed while sock_ip_recv() blocks).
* @return -ENOBUFS, if buffer space is not large enough to store received
* data.
* @return -ENOMEM, if no memory was available to receive @p data.
Expand Down
2 changes: 2 additions & 0 deletions sys/include/net/sock/udp.h
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,8 @@ int sock_udp_get_remote(sock_udp_t *sock, sock_udp_ep_t *ep);
* @return 0, if no received data is available, but everything is in order.
* @return -EADDRNOTAVAIL, if local of @p sock is not given.
* @return -EAGAIN, if @p timeout is `0` and no data is available.
* @return -EINVAL, if @p remote is invalid or @p sock is not properly
* initialized (or closed while sock_udp_recv() blocks).
* @return -ENOBUFS, if buffer space is not large enough to store received
* data.
* @return -ENOMEM, if no memory was available to receive @p data.
Expand Down
5 changes: 4 additions & 1 deletion sys/net/gnrc/sock/gnrc_sock.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ ssize_t gnrc_sock_recv(gnrc_sock_reg_t *reg, gnrc_pktsnip_t **pkt_out,
gnrc_pktsnip_t *pkt, *ip, *netif;
msg_t msg;

if (reg->mbox.cib.mask != (SOCK_MBOX_SIZE - 1)) {
return -EINVAL;
}
#ifdef MODULE_XTIMER
xtimer_t timeout_timer;

Expand Down Expand Up @@ -89,7 +92,7 @@ ssize_t gnrc_sock_recv(gnrc_sock_reg_t *reg, gnrc_pktsnip_t **pkt_out,
#endif
/* Falls Through. */
default:
return -EINTR;
return -EINVAL;
}
/* TODO: discern NETTYPE from remote->family (set in caller), when IPv4
* was implemented */
Expand Down

0 comments on commit c02ee08

Please sign in to comment.