summaryrefslogtreecommitdiffstats
path: root/misc.c
diff options
context:
space:
mode:
authordjm@openbsd.org <djm@openbsd.org>2020-06-26 07:16:38 +0200
committerDamien Miller <djm@mindrot.org>2020-06-26 07:25:24 +0200
commit3d06ff4bbd3dca8054c238d2a94c0da563ef7eee (patch)
tree8eb53997aaeaa09fe20f1f5b060b03c90f8f350f /misc.c
parentupstream: allow "ssh-add -d -" to read keys to be deleted from (diff)
downloadopenssh-3d06ff4bbd3dca8054c238d2a94c0da563ef7eee.tar.xz
openssh-3d06ff4bbd3dca8054c238d2a94c0da563ef7eee.zip
upstream: handle EINTR in waitfd() and timeout_connect() helpers;
bz#3071; ok dtucker@ OpenBSD-Commit-ID: 08fa87be50070bd8b754d9b1ebb1138d7bc9d8ee
Diffstat (limited to 'misc.c')
-rw-r--r--misc.c21
1 files changed, 13 insertions, 8 deletions
diff --git a/misc.c b/misc.c
index f29e9bc3a..4623b5755 100644
--- a/misc.c
+++ b/misc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: misc.c,v 1.152 2020/05/29 11:17:56 dtucker Exp $ */
+/* $OpenBSD: misc.c,v 1.153 2020/06/26 05:16:38 djm Exp $ */
/*
* Copyright (c) 2000 Markus Friedl. All rights reserved.
* Copyright (c) 2005-2020 Damien Miller. All rights reserved.
@@ -253,7 +253,7 @@ waitfd(int fd, int *timeoutp, short events)
errno = oerrno;
if (r > 0)
return 0;
- else if (r == -1 && errno != EAGAIN)
+ else if (r == -1 && errno != EAGAIN && errno != EINTR)
return -1;
else if (r == 0)
break;
@@ -292,12 +292,17 @@ timeout_connect(int sockfd, const struct sockaddr *serv_addr,
return connect(sockfd, serv_addr, addrlen);
set_nonblock(sockfd);
- if (connect(sockfd, serv_addr, addrlen) == 0) {
- /* Succeeded already? */
- unset_nonblock(sockfd);
- return 0;
- } else if (errno != EINPROGRESS)
- return -1;
+ for (;;) {
+ if (connect(sockfd, serv_addr, addrlen) == 0) {
+ /* Succeeded already? */
+ unset_nonblock(sockfd);
+ return 0;
+ } else if (errno == EINTR)
+ continue;
+ else if (errno != EINPROGRESS)
+ return -1;
+ break;
+ }
if (waitfd(sockfd, timeoutp, POLLIN | POLLOUT) == -1)
return -1;