From 6639031e15b23d342efb87cc00fa51233d66b392 Mon Sep 17 00:00:00 2001 From: "Luke T. Shumaker" Date: Fri, 21 Feb 2025 10:32:09 -0700 Subject: libhw: Allow zero-length TCP reads and writes --- libhw/host_net.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'libhw/host_net.c') 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 = { -- cgit v1.2.3-2-g168b