"GOT", but the "O" is a cute, smiling pufferfish. Index | Thread | Search

From:
Josh Rickmar <openbsd+lists@zettaport.com>
Subject:
use correct pipe ends on linux
To:
gameoftrees@openbsd.org
Date:
Tue, 5 Jul 2022 15:12:19 -0400

Download raw body.

Thread
-----------------------------------------------
commit 24b0007a1fd9c963f5e1e243919476e449b5c8dc (linux_pipe)
from: Josh Rickmar <jrick@zettaport.com>
date: Tue Jul  5 19:07:51 2022 UTC
 
 use correct pipe ends on linux
 
 Fixes fdopen errors opening the pipe fds to read ssh-keygen stdout.

 Reported by abieber@
 
diff d68f2c0e20f502d7bea2f0136527683f830b3d6c 24b0007a1fd9c963f5e1e243919476e449b5c8dc
commit - d68f2c0e20f502d7bea2f0136527683f830b3d6c
commit + 24b0007a1fd9c963f5e1e243919476e449b5c8dc
blob - ac1b2637f90cec3243da8a059be58205a4621203
blob + 97e100a388743e949c96ea3ba91a3c80e1d11957
--- lib/sigs.c
+++ lib/sigs.c
@@ -116,11 +116,11 @@ got_sigs_sign_tag_ssh(pid_t *newpid, int *in_fd, int *
 	} else if (pid == 0) {
 		if (close(in_pfd[1]) == -1)
 			err(1, "close");
-		if (close(out_pfd[1]) == -1)
+		if (close(out_pfd[0]) == -1)
 			err(1, "close");
 		if (dup2(in_pfd[0], 0) == -1)
 			err(1, "dup2");
-		if (dup2(out_pfd[0], 1) == -1)
+		if (dup2(out_pfd[1], 1) == -1)
 			err(1, "dup2");
 		if (execv(GOT_TAG_PATH_SSH_KEYGEN, (char **const)argv) == -1)
 			err(1, "execv");
@@ -128,11 +128,11 @@ got_sigs_sign_tag_ssh(pid_t *newpid, int *in_fd, int *
 	}
 	if (close(in_pfd[0]) == -1)
 		return got_error_from_errno("close");
-	if (close(out_pfd[0]) == -1)
+	if (close(out_pfd[1]) == -1)
 		return got_error_from_errno("close");
 	*newpid = pid;
 	*in_fd = in_pfd[1];
-	*out_fd = out_pfd[1];
+	*out_fd = out_pfd[0];
 	return NULL;
 }
 
@@ -342,11 +342,11 @@ got_sigs_verify_tag_ssh(char **msg, struct got_tag_obj
 	} else if (pid == 0) {
 		if (close(in_pfd[1]) == -1)
 			err(1, "close");
-		if (close(out_pfd[1]) == -1)
+		if (close(out_pfd[0]) == -1)
 			err(1, "close");
 		if (dup2(in_pfd[0], 0) == -1)
 			err(1, "dup2");
-		if (dup2(out_pfd[0], 1) == -1)
+		if (dup2(out_pfd[1], 1) == -1)
 			err(1, "dup2");
 		if (execv(GOT_TAG_PATH_SSH_KEYGEN, (char **const)argv) == -1)
 			err(1, "execv");
@@ -356,7 +356,7 @@ got_sigs_verify_tag_ssh(char **msg, struct got_tag_obj
 		error = got_error_from_errno("close");
 		goto done;
 	}
-	if (close(out_pfd[0]) == -1) {
+	if (close(out_pfd[1]) == -1) {
 		error = got_error_from_errno("close");
 		goto done;
 	}
@@ -377,7 +377,7 @@ got_sigs_verify_tag_ssh(char **msg, struct got_tag_obj
 		goto done;
 	}
 
-	out = fdopen(out_pfd[1], "r");
+	out = fdopen(out_pfd[0], "r");
 	if (out == NULL) {
 		error = got_error_from_errno("fdopen");
 		goto done;
@@ -388,7 +388,7 @@ got_sigs_verify_tag_ssh(char **msg, struct got_tag_obj
 	error = buf_putc(buf, '\0');
 	if (error)
 		goto done;
-	if (close(out_pfd[1]) == -1) {
+	if (close(out_pfd[0]) == -1) {
 		error = got_error_from_errno("close");
 		goto done;
 	}