diff options
author | 2014-07-10 08:59:15 +0000 | |
---|---|---|
committer | 2014-07-10 08:59:15 +0000 | |
commit | 8e42e03f73edacce05d8d9051122ed8dc38655cd (patch) | |
tree | 699dd53757a4668d786a88ed9267d358e4e9fa7f /lib/libssl/src | |
parent | sync (diff) | |
download | wireguard-openbsd-8e42e03f73edacce05d8d9051122ed8dc38655cd.tar.xz wireguard-openbsd-8e42e03f73edacce05d8d9051122ed8dc38655cd.zip |
check return value of write.
ok beck@ jsing@
Diffstat (limited to 'lib/libssl/src')
-rw-r--r-- | lib/libssl/src/apps/s_server.c | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/lib/libssl/src/apps/s_server.c b/lib/libssl/src/apps/s_server.c index 1c13d5517d6..45c4f5fa9c6 100644 --- a/lib/libssl/src/apps/s_server.c +++ b/lib/libssl/src/apps/s_server.c @@ -1,4 +1,4 @@ -/* $OpenBSD: s_server.c,v 1.56 2014/07/09 21:02:35 tedu Exp $ */ +/* $OpenBSD: s_server.c,v 1.57 2014/07/10 08:59:15 bcook Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -1709,9 +1709,20 @@ sv_body(char *hostname, int s, unsigned char *context) again: i = SSL_read(con, (char *) buf, bufsize); switch (SSL_get_error(con, i)) { - case SSL_ERROR_NONE: - write(fileno(stdout), buf, - (unsigned int) i); + case SSL_ERROR_NONE: { + int len, n; + for (len = 0; len < i;) { + do { + n = write(fileno(stdout), buf + len, i - len); + } while (n == -1 && errno == EINTR); + + if (n < 0) { + BIO_printf(bio_s_out, "ERROR\n"); + goto err; + } + len += n; + } + } if (SSL_pending(con)) goto again; break; |