]> www.infradead.org Git - users/dwmw2/openconnect.git/commitdiff
run_hip_script: made error handling consistent
authorNikos Mavrogiannopoulos <nmav@redhat.com>
Thu, 12 Nov 2020 14:36:06 +0000 (15:36 +0100)
committerNikos Mavrogiannopoulos <n.mavrogiannopoulos@gmail.com>
Tue, 17 Nov 2020 12:53:13 +0000 (13:53 +0100)
Signed-off-by: Nikos Mavrogiannopoulos <nmav@redhat.com>
gpst.c

diff --git a/gpst.c b/gpst.c
index 686bde2baf8fe23f0e9aa5ec6c609b978de852b9..27397af6db0c15dd39d4cbc26db5a6ce8ce11fa0 100644 (file)
--- a/gpst.c
+++ b/gpst.c
@@ -909,14 +909,17 @@ static int run_hip_script(struct openconnect_info *vpninfo)
        if (pipe2(pipefd, O_CLOEXEC))
 #endif
        {
-               if (pipe(pipefd))
-                       goto out;
+               if (pipe(pipefd)) {
+                       vpn_progress(vpninfo, PRG_ERR, _("Failed to create pipe for HIP script\n"));
+                       return -EPERM;
+               }
                set_fd_cloexec(pipefd[0]);
                set_fd_cloexec(pipefd[1]);
        }
        child = fork();
        if (child == -1) {
-               goto out;
+               vpn_progress(vpninfo, PRG_ERR, _("Failed to fork for HIP script\n"));
+               return -EPERM;
        } else if (child > 0) {
                /* in parent: read report from child */
                struct oc_text_buf *report_buf = buf_alloc();
@@ -979,7 +982,6 @@ static int run_hip_script(struct openconnect_info *vpninfo)
                hip_argv[i++] = NULL;
                execv(hip_argv[0], (char **)hip_argv);
 
-       out:
                vpn_progress(vpninfo, PRG_ERR,
                                 _("Failed to exec HIP script %s\n"), hip_argv[0]);
                exit(1);