diff mbox series

[1/4] libmpathcmd: check len parameter in mpath_recv_reply_data()

Message ID 20240718191421.110487-2-mwilck@suse.com (mailing list archive)
State Not Applicable, archived
Delegated to: christophe varoqui
Headers show
Series multipath-tools: coverity fixes | expand

Commit Message

Martin Wilck July 18, 2024, 7:14 p.m. UTC
Found by coverity. Callers check this parameter already, but
the function is exported by libmpathcmd, so make sure we don't
write '\0' to reply[-1].

Signed-off-by: Martin Wilck <mwilck@suse.com>
---
 libmpathcmd/mpath_cmd.c | 2 ++
 1 file changed, 2 insertions(+)
diff mbox series

Patch

diff --git a/libmpathcmd/mpath_cmd.c b/libmpathcmd/mpath_cmd.c
index 60b2d96..d7c3371 100644
--- a/libmpathcmd/mpath_cmd.c
+++ b/libmpathcmd/mpath_cmd.c
@@ -170,6 +170,8 @@  int mpath_recv_reply_data(int fd, char *reply, size_t len,
 {
 	ssize_t ret;
 
+	if (len <= 0)
+		return 0;
 	ret = read_all(fd, reply, len, timeout);
 	if (ret < 0)
 		return ret;