From: "plaisthos (Code Review)" Date: Thu, 26 Sep 2024 12:41:25 +0000 In-Reply-To: References: Reply-To: arne-openvpn@...1227..., openvpn-devel@lists.sourceforge.net, frank@...2641... Message-ID: <7f58b26a6997120bb193d7f1871849caf6526dee-EmailReplacePatchSet-HTML@...2715...> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Disposition: inline Content-Type: multipart/alternative; boundary="X1yAoWjsin8="; charset=UTF-8 Subject: [Openvpn-devel] [S] Change in openvpn[master]: Fix socketpair return status not being checked in port share code List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: flichtenheld Cc: openvpn-devel --X1yAoWjsin8= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Attention is currently required from: plaisthos. Hello flichtenheld, I'd like you to reexamine a change. Please visit http://gerrit.openvpn.net/c/openvpn/+/770?usp=3Demail to look at the new patch set (#2). Change subject: Fix socketpair return status not being checked in port shar= e code ...................................................................... Fix socketpair return status not being checked in port share code found by Coverity after tun_afunix introduced another call to socketpair, so it started to complain that we only check the return code in 4 of 5 cases. Change-Id: Id99a3ba13c0f1d0bc7e4699fb67ee9dff6221639 Signed-off-by: Arne Schwabe --- M src/openvpn/ps.c 1 file changed, 8 insertions(+), 2 deletions(-) git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/70/770/2 diff --git a/src/openvpn/ps.c b/src/openvpn/ps.c index 4ca3a12..04bee8d 100644 --- a/src/openvpn/ps.c +++ b/src/openvpn/ps.c @@ -234,7 +234,12 @@ } else { - socketpair(PF_UNIX, SOCK_DGRAM, 0, sd_null); + if (!(socketpair(AF_UNIX, SOCK_DGRAM, 0, sd_null) =3D=3D 0)) + { + msg(M_WARN|M_ERRNO, "PORT SHARE: socketpair failed -- unab= le to communicate with background process " + "(%d, %d)", sd, sd_send); + goto done; + } memcpy(CMSG_DATA(h), &sd_null[0], sizeof(sd_null[0])); } @@ -246,6 +251,7 @@ ); } +done: close_socket_if_defined(sd_null[0]); close_socket_if_defined(sd_null[1]); free(mesg.msg_control); @@ -845,7 +851,7 @@ * Make a socket for foreground and background processes * to communicate. */ - if (socketpair(PF_UNIX, SOCK_DGRAM, 0, fd) =3D=3D -1) + if (!(socketpair(PF_UNIX, SOCK_DGRAM, 0, fd) =3D=3D 0)) { msg(M_WARN, "PORT SHARE: socketpair call failed"); goto error; -- To view, visit http://gerrit.openvpn.net/c/openvpn/+/770?usp=3Demail To unsubscribe, or for help writing mail filters, visit http://gerrit.openv= pn.net/settings Gerrit-Project: openvpn Gerrit-Branch: master Gerrit-Change-Id: Id99a3ba13c0f1d0bc7e4699fb67ee9dff6221639 Gerrit-Change-Number: 770 Gerrit-PatchSet: 2 Gerrit-Owner: plaisthos Gerrit-Reviewer: flichtenheld Gerrit-CC: openvpn-devel Gerrit-Attention: plaisthos Gerrit-MessageType: newpatchset --X1yAoWjsin8= Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

Attention is currently required from: plaisthos.

plaisthos uploaded patch set #2 to this change.

<= a href=3D"http://gerrit.openvpn.net/c/openvpn/+/770?usp=3Demail">View Chang= e

Fix socketpair return status not being checked in port share code
=
found by Coverity after tun_afunix introduced another call to
socket= pair, so it started to complain that we only check the
return code in 4 = of 5 cases.

Change-Id: Id99a3ba13c0f1d0bc7e4699fb67ee9dff6221639
= Signed-off-by: Arne Schwabe <arne@...1227...>
---
M src/openvpn= /ps.c
1 file changed, 8 insertions(+), 2 deletions(-)

git pull=
 ssh://gerrit.openvpn.net:29418/openvpn refs/changes/70/770/2
diff =
--git a/src/openvpn/ps.c b/src/openvpn/ps.c
index 4ca3a12..= 04bee8d 100644
--- a/src/openvpn/ps.c
+++ b= /src/openvpn/ps.c
@@ -234,7 +234,12 @@
= }
else
{
<= span style=3D"color: hsl(0, 100%, 40%);">- socketpair(PF_UNIX, S= OCK_DGRAM, 0, sd_null);
+ if (!(socketpair(AF_UNIX, SOCK_DGRAM, 0, sd_null) =3D=3D 0)= )
+ {
+ msg(M_WA= RN|M_ERRNO, "PORT SHARE: socketpair failed -- unable to communicate wi= th background process "
+ "(%d, %d)", sd, sd_send);
= + goto done;
+ } memcpy(CMSG_DATA(h), &sd_null[0], sizeof(sd_null[0]= ));
}

@@ -246,6 = +251,7 @@
);
}

+done= :
close_socket_if_defined(sd_null[0]);
<= span> close_socket_if_defined(sd_null[1]);

= free(mesg.msg_control);
@@ -845,7 +851,7 @@
* Make a socket for foreground and background processes

<= span> * to communicate.

*/
- if (socketpair(PF_UNIX, SOCK_DGRAM, 0, = fd) =3D=3D -1)
+ i= f (!(socketpair(PF_UNIX, SOCK_DGRAM, 0, fd) =3D=3D 0))
= {
msg(M_WARN, "PORT SHARE: socketpair call f= ailed");
goto error;
<= br>

To view, visit change 770. To unsubscribe, or for help writing mail = filters, visit settings.=

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Id99a3ba13c0f1d0bc7e4699fb67= ee9dff6221639
Gerrit-Change-Number: 770
Gerrit-PatchSet: 2
Gerrit-Owner: plaisthos <arne-openvpn@...1711...= 27...>
Gerrit-Reviewer: flichtenheld <frank@...2716...= 1...>
Gerrit-CC: openvpn-devel <openvpn-devel@...1484...= ts.sourceforge.net>
Gerrit-Attention: plaisthos <arne-openvpn@...220...= ..1227...>
Gerrit-MessageType: newpatchset
--X1yAoWjsin8=--