summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>2001-03-06 00:33:05 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>2001-03-06 00:33:05 +0000
commit5fb1ee3f97289074584bb6049f3126172b2e03be (patch)
tree718d5304247131d39273e0ac9bb95a2119f274db /usr.bin
parent1404374d3bc7b503a4034b6a2952941ed7a6754f (diff)
EINTR/EAGAIN handling is required in more cases
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/ssh/authfd.c6
-rw-r--r--usr.bin/ssh/cli.c10
-rw-r--r--usr.bin/ssh/ssh-agent.c24
3 files changed, 30 insertions, 10 deletions
diff --git a/usr.bin/ssh/authfd.c b/usr.bin/ssh/authfd.c
index d375dbad8a2..657dbfd3878 100644
--- a/usr.bin/ssh/authfd.c
+++ b/usr.bin/ssh/authfd.c
@@ -35,7 +35,7 @@
*/
#include "includes.h"
-RCSID("$OpenBSD: authfd.c,v 1.37 2001/03/04 17:42:27 millert Exp $");
+RCSID("$OpenBSD: authfd.c,v 1.38 2001/03/06 00:33:03 deraadt Exp $");
#include <openssl/evp.h>
@@ -118,6 +118,8 @@ ssh_request_reply(AuthenticationConnection *auth, Buffer *request, Buffer *reply
len = 4;
while (len > 0) {
l = read(auth->fd, buf + 4 - len, len);
+ if (l == -1 && (errno == EAGAIN || errno == EINTR))
+ continue;
if (l <= 0) {
error("Error reading response length from authentication socket.");
return 0;
@@ -137,6 +139,8 @@ ssh_request_reply(AuthenticationConnection *auth, Buffer *request, Buffer *reply
if (l > sizeof(buf))
l = sizeof(buf);
l = read(auth->fd, buf, l);
+ if (l == -1 && (errno == EAGAIN || errno == EINTR))
+ continue;
if (l <= 0) {
error("Error reading response from authentication socket.");
return 0;
diff --git a/usr.bin/ssh/cli.c b/usr.bin/ssh/cli.c
index 620431e9bf2..8f0b2b87e36 100644
--- a/usr.bin/ssh/cli.c
+++ b/usr.bin/ssh/cli.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cli.c,v 1.10 2001/03/01 03:38:33 deraadt Exp $ */
+/* $OpenBSD: cli.c,v 1.11 2001/03/06 00:33:04 deraadt Exp $ */
/*
* Copyright (c) 2000 Markus Friedl. All rights reserved.
@@ -25,7 +25,7 @@
*/
#include "includes.h"
-RCSID("$OpenBSD: cli.c,v 1.10 2001/03/01 03:38:33 deraadt Exp $");
+RCSID("$OpenBSD: cli.c,v 1.11 2001/03/06 00:33:04 deraadt Exp $");
#include "xmalloc.h"
#include "log.h"
@@ -136,12 +136,16 @@ cli_read(char* buf, int size, int echo)
{
char ch = 0;
int i = 0;
+ int n;
if (!echo)
cli_echo_disable();
while (ch != '\n') {
- if (read(cli_input, &ch, 1) != 1)
+ n = read(cli_input, &ch, 1);
+ if (n == -1 && (errno == EAGAIN || errno == EINTR))
+ continue;
+ if (n != 1)
break;
if (ch == '\n' || intr != 0)
break;
diff --git a/usr.bin/ssh/ssh-agent.c b/usr.bin/ssh/ssh-agent.c
index 92fe02de15e..23ca3200b55 100644
--- a/usr.bin/ssh/ssh-agent.c
+++ b/usr.bin/ssh/ssh-agent.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ssh-agent.c,v 1.51 2001/03/02 18:54:31 deraadt Exp $ */
+/* $OpenBSD: ssh-agent.c,v 1.52 2001/03/06 00:33:04 deraadt Exp $ */
/*
* Author: Tatu Ylonen <ylo@cs.hut.fi>
@@ -37,7 +37,7 @@
*/
#include "includes.h"
-RCSID("$OpenBSD: ssh-agent.c,v 1.51 2001/03/02 18:54:31 deraadt Exp $");
+RCSID("$OpenBSD: ssh-agent.c,v 1.52 2001/03/06 00:33:04 deraadt Exp $");
#include <openssl/evp.h>
#include <openssl/md5.h>
@@ -631,9 +631,15 @@ after_select(fd_set *readset, fd_set *writeset)
case AUTH_CONNECTION:
if (buffer_len(&sockets[i].output) > 0 &&
FD_ISSET(sockets[i].fd, writeset)) {
- len = write(sockets[i].fd,
- buffer_ptr(&sockets[i].output),
- buffer_len(&sockets[i].output));
+ do {
+ len = write(sockets[i].fd,
+ buffer_ptr(&sockets[i].output),
+ buffer_len(&sockets[i].output));
+ if (len == -1 && (errno == EAGAIN ||
+ errno == EINTR))
+ continue;
+ break;
+ } while (1);
if (len <= 0) {
shutdown(sockets[i].fd, SHUT_RDWR);
close(sockets[i].fd);
@@ -645,7 +651,13 @@ after_select(fd_set *readset, fd_set *writeset)
buffer_consume(&sockets[i].output, len);
}
if (FD_ISSET(sockets[i].fd, readset)) {
- len = read(sockets[i].fd, buf, sizeof(buf));
+ do {
+ len = read(sockets[i].fd, buf, sizeof(buf));
+ if (len == -1 && (errno == EAGAIN ||
+ errno == EINTR))
+ continue;
+ break;
+ } while (1);
if (len <= 0) {
shutdown(sockets[i].fd, SHUT_RDWR);
close(sockets[i].fd);