summaryrefslogtreecommitdiff
path: root/ssh-sk-client.c
diff options
context:
space:
mode:
authordtucker@openbsd.org <dtucker@openbsd.org>2020-01-23 07:10:22 +0000
committerDarren Tucker <dtucker@dtucker.net>2020-01-23 18:51:25 +1100
commit3bf2a6ac791d64046a537335a0f1d5e43579c5ad (patch)
tree76fcc0f1be306541c074be4aed3aca66023f0962 /ssh-sk-client.c
parente027c044c796f3a01081a91bee55741204283f28 (diff)
upstream: Replace all calls to signal(2) with a wrapper around
sigaction(2). This wrapper blocks all other signals during the handler preventing races between handlers, and sets SA_RESTART which should reduce the potential for short read/write operations. OpenBSD-Commit-ID: 5e047663fd77a40d7b07bdabe68529df51fd2519
Diffstat (limited to 'ssh-sk-client.c')
-rw-r--r--ssh-sk-client.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/ssh-sk-client.c b/ssh-sk-client.c
index 359327b68..8d7e6c305 100644
--- a/ssh-sk-client.c
+++ b/ssh-sk-client.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ssh-sk-client.c,v 1.6 2020/01/21 07:07:31 djm Exp $ */ 1/* $OpenBSD: ssh-sk-client.c,v 1.7 2020/01/23 07:10:22 dtucker Exp $ */
2/* 2/*
3 * Copyright (c) 2019 Google LLC 3 * Copyright (c) 2019 Google LLC
4 * 4 *
@@ -39,6 +39,7 @@
39#include "digest.h" 39#include "digest.h"
40#include "pathnames.h" 40#include "pathnames.h"
41#include "ssh-sk.h" 41#include "ssh-sk.h"
42#include "misc.h"
42 43
43/* #define DEBUG_SK 1 */ 44/* #define DEBUG_SK 1 */
44 45
@@ -73,13 +74,13 @@ start_helper(int *fdp, pid_t *pidp, void (**osigchldp)(int))
73 error("socketpair: %s", strerror(errno)); 74 error("socketpair: %s", strerror(errno));
74 return SSH_ERR_SYSTEM_ERROR; 75 return SSH_ERR_SYSTEM_ERROR;
75 } 76 }
76 osigchld = signal(SIGCHLD, SIG_DFL); 77 osigchld = ssh_signal(SIGCHLD, SIG_DFL);
77 if ((pid = fork()) == -1) { 78 if ((pid = fork()) == -1) {
78 oerrno = errno; 79 oerrno = errno;
79 error("fork: %s", strerror(errno)); 80 error("fork: %s", strerror(errno));
80 close(pair[0]); 81 close(pair[0]);
81 close(pair[1]); 82 close(pair[1]);
82 signal(SIGCHLD, osigchld); 83 ssh_signal(SIGCHLD, osigchld);
83 errno = oerrno; 84 errno = oerrno;
84 return SSH_ERR_SYSTEM_ERROR; 85 return SSH_ERR_SYSTEM_ERROR;
85 } 86 }
@@ -220,7 +221,7 @@ client_converse(struct sshbuf *msg, struct sshbuf **respp, u_int type)
220 } 221 }
221 sshbuf_free(req); 222 sshbuf_free(req);
222 sshbuf_free(resp); 223 sshbuf_free(resp);
223 signal(SIGCHLD, osigchld); 224 ssh_signal(SIGCHLD, osigchld);
224 errno = oerrno; 225 errno = oerrno;
225 return r; 226 return r;
226 227