From a3f7cd235a4aaf7771763d3b0b27d96dd4f5f1c1 Mon Sep 17 00:00:00 2001 From: John Kacur Date: Tue, 1 Nov 2022 09:30:40 -0400 Subject: [PATCH 1/4] rt-tests: hackbench: Add error checking to connect and getsockname Add error checking around the calls connect and getsockname Signed-off-by: John Kacur --- src/hackbench/hackbench.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/hackbench/hackbench.c b/src/hackbench/hackbench.c index 18c928480103..8c6d83520e57 100644 --- a/src/hackbench/hackbench.c +++ b/src/hackbench/hackbench.c @@ -130,14 +130,16 @@ static int inet_socketpair(int fds[2]) if (bind(s1, &sin, len) < 0) barf("bind"); - getsockname(s1, &sin, &len); + if (getsockname(s1, &sin, &len) < 0) + barf("getsockname"); if (listen(s1, 10) < 0) barf("listen"); if (ioctl(s2, FIONBIO, &ul) < 0) barf("ioctl"); if (ioctl(s1, FIONBIO, &ul) < 0) barf("ioctl"); - connect(s2, &sin, len); + if (connect(s2, &sin, len) < 0) + barf("connect"); if ((fds[0] = accept(s1, &sin, &len)) < 0) barf("accept"); ul = 0; -- 2.38.1