summaryrefslogtreecommitdiff
path: root/libhw/host_net.c
diff options
context:
space:
mode:
authorLuke T. Shumaker <lukeshu@lukeshu.com>2025-02-21 10:32:09 -0700
committerLuke T. Shumaker <lukeshu@lukeshu.com>2025-02-21 10:33:02 -0700
commit6639031e15b23d342efb87cc00fa51233d66b392 (patch)
tree4856b9797d914d76e2df0c524a13a173af87baae /libhw/host_net.c
parent57430f7c8de034ff4bdba5cdd9996316a4767fd7 (diff)
libhw: Allow zero-length TCP reads and writes
Diffstat (limited to 'libhw/host_net.c')
-rw-r--r--libhw/host_net.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/libhw/host_net.c b/libhw/host_net.c
index 505c7dc..eee293e 100644
--- a/libhw/host_net.c
+++ b/libhw/host_net.c
@@ -229,6 +229,9 @@ static void *hostnet_pthread_read(void *_args) {
static ssize_t hostnet_tcp_read(struct _hostnet_tcp_conn *conn, void *buf, size_t count) {
assert(conn);
+ assert(count == 0 || buf);
+ if (count == 0)
+ return 0;
ssize_t ret;
struct hostnet_pthread_read_args args = {
@@ -287,6 +290,9 @@ static void *hostnet_pthread_write(void *_args) {
static ssize_t hostnet_tcp_write(struct _hostnet_tcp_conn *conn, void *buf, size_t count) {
assert(conn);
+ assert(count == 0 || buf);
+ if (count == 0)
+ return 0;
ssize_t ret;
struct hostnet_pthread_write_args args = {