From 783629df08b7c08037f282b0e85ca40fa82cdaf4 Mon Sep 17 00:00:00 2001 From: Mo Chen Date: Tue, 12 Sep 2023 16:27:32 -0500 Subject: [PATCH 1/3] Fix CID-1518256 * Read the return value from read() into a dummy variable. --- iocore/net/AsyncSignalEventIO.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/iocore/net/AsyncSignalEventIO.cc b/iocore/net/AsyncSignalEventIO.cc index f6f615456cc..de22bf40113 100644 --- a/iocore/net/AsyncSignalEventIO.cc +++ b/iocore/net/AsyncSignalEventIO.cc @@ -40,6 +40,7 @@ AsyncSignalEventIO::process_event(int flags) static_cast(read(_fd, &counter, sizeof(uint64_t))); #else char dummy[1024]; - static_cast(read(_fd, &dummy[0], 1024)); + [[maybe_unused]] ssize_t ret = read(_fd, &dummy[0], 1024); + ink_assert(ret >= 0); #endif } From 39ee68a17522b335d470f595d7183dd77484dfd8 Mon Sep 17 00:00:00 2001 From: Mo Chen Date: Thu, 14 Sep 2023 14:55:09 -0500 Subject: [PATCH 2/3] Fix the other #if branch --- iocore/net/AsyncSignalEventIO.cc | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/iocore/net/AsyncSignalEventIO.cc b/iocore/net/AsyncSignalEventIO.cc index de22bf40113..97aebc2ac6a 100644 --- a/iocore/net/AsyncSignalEventIO.cc +++ b/iocore/net/AsyncSignalEventIO.cc @@ -35,12 +35,13 @@ AsyncSignalEventIO::start(EventLoop l, int fd, int events) void AsyncSignalEventIO::process_event(int flags) { + [[maybe_unused]] ssize_t ret; #if HAVE_EVENTFD uint64_t counter; - static_cast(read(_fd, &counter, sizeof(uint64_t))); + ret = read(_fd, &counter, sizeof(uint64_t)); + ink_assert(ret >= 0); #else char dummy[1024]; - [[maybe_unused]] ssize_t ret = read(_fd, &dummy[0], 1024); - ink_assert(ret >= 0); + ret = read(_fd, &dummy[0], 1024); #endif } From 804ad3fcc8cc795c4235139a694c3acee174d031 Mon Sep 17 00:00:00 2001 From: Mo Chen Date: Thu, 14 Sep 2023 14:55:41 -0500 Subject: [PATCH 3/3] Update AsyncSignalEventIO.cc --- iocore/net/AsyncSignalEventIO.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/iocore/net/AsyncSignalEventIO.cc b/iocore/net/AsyncSignalEventIO.cc index 97aebc2ac6a..0a3483fb05b 100644 --- a/iocore/net/AsyncSignalEventIO.cc +++ b/iocore/net/AsyncSignalEventIO.cc @@ -43,5 +43,6 @@ AsyncSignalEventIO::process_event(int flags) #else char dummy[1024]; ret = read(_fd, &dummy[0], 1024); + ink_assert(ret >= 0); #endif }