[Openvpn-devel,XS] Change in openvpn[master]: Fix socketpair return status not being checked in port share code

Message ID 1838210b47c0914e3119d4f491d6c9a6f8bb5c35-HTML@gerrit.openvpn.net
State New
Headers show
Series [Openvpn-devel,XS] Change in openvpn[master]: Fix socketpair return status not being checked in port share code | expand

Commit Message

cron2 (Code Review) Sept. 25, 2024, 2:06 p.m. UTC
Attention is currently required from: flichtenheld.

Hello flichtenheld,

I'd like you to do a code review.
Please visit

    http://gerrit.openvpn.net/c/openvpn/+/770?usp=email

to review the following change.


Change subject: Fix socketpair return status not being checked in port share 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
---
M src/openvpn/ps.c
1 file changed, 7 insertions(+), 1 deletion(-)



  git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/70/770/1

Patch

diff --git a/src/openvpn/ps.c b/src/openvpn/ps.c
index 4ca3a12..129f65c 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))
+            {
+                msg(M_WARN|M_ERRNO, "PORT SHARE: socketpair failed -- unable 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);