net: socket: Return ENOTSUP for unknown socket type in recvfrom()
If we for some reason are supplied unsupported socket type in recvfrom(), then return ENOTSUP error to the caller instead of silently accept it by returning 0. Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
This commit is contained in:
parent
5539a47eb6
commit
1961adfb96
|
@ -1684,11 +1684,13 @@ ssize_t zsock_recvfrom_ctx(struct net_context *ctx, void *buf, size_t max_len,
|
|||
return zsock_recv_dgram(ctx, NULL, buf, max_len, flags, src_addr, addrlen);
|
||||
} else if (sock_type == SOCK_STREAM) {
|
||||
return zsock_recv_stream(ctx, NULL, buf, max_len, flags);
|
||||
} else {
|
||||
__ASSERT(0, "Unknown socket type");
|
||||
}
|
||||
|
||||
return 0;
|
||||
__ASSERT(0, "Unknown socket type");
|
||||
|
||||
errno = ENOTSUP;
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
ssize_t z_impl_zsock_recvfrom(int sock, void *buf, size_t max_len, int flags,
|
||||
|
|
Loading…
Reference in a new issue