diff --git a/sys/include/net/sock/ip.h b/sys/include/net/sock/ip.h index 4ef4cf70530087c797f25b4bb5c57610b91ccc03..17950625d37ff213e167ad843685fb5227c4c641 100644 --- a/sys/include/net/sock/ip.h +++ b/sys/include/net/sock/ip.h @@ -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. diff --git a/sys/include/net/sock/udp.h b/sys/include/net/sock/udp.h index 39cad6194539d3d0f6fbf7fd5f1f68afbfd43a6b..82136a1552e6827b8bbbd48de82e4ea1c2695e3c 100644 --- a/sys/include/net/sock/udp.h +++ b/sys/include/net/sock/udp.h @@ -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. diff --git a/sys/net/gnrc/sock/gnrc_sock.c b/sys/net/gnrc/sock/gnrc_sock.c index 65c88876cfee52ce51b2eab766d47866bcb0629e..89108985d56aee5193b4f6d8750dcf86b0c10fa5 100644 --- a/sys/net/gnrc/sock/gnrc_sock.c +++ b/sys/net/gnrc/sock/gnrc_sock.c @@ -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; @@ -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 */