1
0
mirror of https://xff.cz/git/u-boot/ synced 2025-09-02 17:22:22 +02:00

sandbox: eth-raw: Correct valid socket test in send/recv

In open, the socket is correctly checked to be -1 in the error case.
In send and recv, we checked for 0, but that is a valid socket number.

Correct this by checking for -1 as a bad socket everywhere.

Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
Joe Hershberger
2018-07-02 14:47:44 -05:00
parent 82a115fdec
commit 97367df109

View File

@@ -156,7 +156,7 @@ int sandbox_eth_raw_os_send(void *packet, int length,
int retval; int retval;
struct udphdr *udph = packet + sizeof(struct iphdr); struct udphdr *udph = packet + sizeof(struct iphdr);
if (!priv->sd || !priv->device) if (priv->sd < 0 || !priv->device)
return -EINVAL; return -EINVAL;
/* /*
@@ -221,7 +221,7 @@ int sandbox_eth_raw_os_recv(void *packet, int *length,
int retval; int retval;
int saddr_size; int saddr_size;
if (!priv->sd || !priv->device) if (priv->sd < 0 || !priv->device)
return -EINVAL; return -EINVAL;
saddr_size = sizeof(struct sockaddr); saddr_size = sizeof(struct sockaddr);
retval = recvfrom(priv->sd, packet, 1536, 0, retval = recvfrom(priv->sd, packet, 1536, 0,