diff options
author | Joe Hershberger | 2018-07-02 14:47:44 -0500 |
---|---|---|
committer | Joe Hershberger | 2018-07-26 14:08:17 -0500 |
commit | 97367df109b845d0bd93eef3f507d259668e8843 (patch) | |
tree | d70132b7f3f5f1ceff96ba72be6f3eab583b7046 /arch/sandbox/cpu/eth-raw-os.c | |
parent | 82a115fdec875d7e8dc601fe0e1b12859814c91c (diff) |
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>
Diffstat (limited to 'arch/sandbox/cpu/eth-raw-os.c')
-rw-r--r-- | arch/sandbox/cpu/eth-raw-os.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/arch/sandbox/cpu/eth-raw-os.c b/arch/sandbox/cpu/eth-raw-os.c index e054a0702a6..61f23ed2104 100644 --- a/arch/sandbox/cpu/eth-raw-os.c +++ b/arch/sandbox/cpu/eth-raw-os.c @@ -156,7 +156,7 @@ int sandbox_eth_raw_os_send(void *packet, int length, int retval; struct udphdr *udph = packet + sizeof(struct iphdr); - if (!priv->sd || !priv->device) + if (priv->sd < 0 || !priv->device) return -EINVAL; /* @@ -221,7 +221,7 @@ int sandbox_eth_raw_os_recv(void *packet, int *length, int retval; int saddr_size; - if (!priv->sd || !priv->device) + if (priv->sd < 0 || !priv->device) return -EINVAL; saddr_size = sizeof(struct sockaddr); retval = recvfrom(priv->sd, packet, 1536, 0, |