From f618965eb719182c66cba456ad93dd4ec39d6fd0 Mon Sep 17 00:00:00 2001 From: matt335672 <30179339+matt335672@users.noreply.github.com> Date: Mon, 10 Mar 2025 14:28:24 +0000 Subject: [PATCH] Fix coverity warning concerning unchecked return Coverity insists the return value from read() is unchecked. This seems to not be true to me, but adding a complete sanity check seems to fix it. --- common/os_calls.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/common/os_calls.c b/common/os_calls.c index 15ee6a67..ac12cff8 100644 --- a/common/os_calls.c +++ b/common/os_calls.c @@ -4294,7 +4294,8 @@ g_fips_mode_enabled(void) if (fd >= 0) { - if (read(fd, buff, sizeof(buff)) > 0) + ssize_t res = read(fd, buff, sizeof(buff)); + if (res > 0 && (size_t)res < sizeof(buff)) { rv = (buff[0] != '0'); }