summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbeck <>2015-09-10 10:59:22 +0000
committerbeck <>2015-09-10 10:59:22 +0000
commitb7f746543bde6f57a62b85be0b7f48844180f2a0 (patch)
tree6b5726cb80f4c19a53329fd4497ee1da5d5546dc
parentffbb5cea377ce5384766b197519c10264d878196 (diff)
downloadopenbsd-b7f746543bde6f57a62b85be0b7f48844180f2a0.tar.gz
openbsd-b7f746543bde6f57a62b85be0b7f48844180f2a0.tar.bz2
openbsd-b7f746543bde6f57a62b85be0b7f48844180f2a0.zip
comment for errno clobbering, to indicate why we do this.
ok deraadt@ jsing@
-rw-r--r--src/lib/libtls/tls.c6
-rw-r--r--src/lib/libtls/tls_init.38
2 files changed, 9 insertions, 5 deletions
diff --git a/src/lib/libtls/tls.c b/src/lib/libtls/tls.c
index 448b048b33..4378c5980a 100644
--- a/src/lib/libtls/tls.c
+++ b/src/lib/libtls/tls.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: tls.c,v 1.22 2015/09/10 10:26:49 beck Exp $ */ 1/* $OpenBSD: tls.c,v 1.23 2015/09/10 10:59:22 beck Exp $ */
2/* 2/*
3 * Copyright (c) 2014 Joel Sing <jsing@openbsd.org> 3 * Copyright (c) 2014 Joel Sing <jsing@openbsd.org>
4 * 4 *
@@ -379,6 +379,7 @@ tls_handshake(struct tls *ctx)
379 else if ((ctx->flags & TLS_SERVER_CONN) != 0) 379 else if ((ctx->flags & TLS_SERVER_CONN) != 0)
380 rv = tls_handshake_server(ctx); 380 rv = tls_handshake_server(ctx);
381 381
382 /* Prevent callers from performing incorrect error handling */
382 errno = 0; 383 errno = 0;
383 return (rv); 384 return (rv);
384} 385}
@@ -406,6 +407,7 @@ tls_read(struct tls *ctx, void *buf, size_t buflen)
406 407
407 rv = (ssize_t)tls_ssl_error(ctx, ctx->ssl_conn, ssl_ret, "read"); 408 rv = (ssize_t)tls_ssl_error(ctx, ctx->ssl_conn, ssl_ret, "read");
408 out: 409 out:
410 /* Prevent callers from performing incorrect error handling */
409 errno = 0; 411 errno = 0;
410 return (rv); 412 return (rv);
411} 413}
@@ -433,6 +435,7 @@ tls_write(struct tls *ctx, const void *buf, size_t buflen)
433 435
434 rv = (ssize_t)tls_ssl_error(ctx, ctx->ssl_conn, ssl_ret, "write"); 436 rv = (ssize_t)tls_ssl_error(ctx, ctx->ssl_conn, ssl_ret, "write");
435 out: 437 out:
438 /* Prevent callers from performing incorrect error handling */
436 errno = 0; 439 errno = 0;
437 return (rv); 440 return (rv);
438} 441}
@@ -470,6 +473,7 @@ tls_close(struct tls *ctx)
470 ctx->socket = -1; 473 ctx->socket = -1;
471 } 474 }
472 out: 475 out:
476 /* Prevent callers from performing incorrect error handling */
473 errno = 0; 477 errno = 0;
474 return (rv); 478 return (rv);
475} 479}
diff --git a/src/lib/libtls/tls_init.3 b/src/lib/libtls/tls_init.3
index 17822d444d..1c27c9be2c 100644
--- a/src/lib/libtls/tls_init.3
+++ b/src/lib/libtls/tls_init.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: tls_init.3,v 1.26 2015/09/10 09:10:42 jsing Exp $ 1.\" $OpenBSD: tls_init.3,v 1.27 2015/09/10 10:59:22 beck Exp $
2.\" 2.\"
3.\" Copyright (c) 2014 Ted Unangst <tedu@openbsd.org> 3.\" Copyright (c) 2014 Ted Unangst <tedu@openbsd.org>
4.\" 4.\"
@@ -435,16 +435,16 @@ and
435function families, have two special return values: 435function families, have two special return values:
436.Pp 436.Pp
437.Bl -tag -width "TLS_WRITE_AGAIN" -offset indent -compact 437.Bl -tag -width "TLS_WRITE_AGAIN" -offset indent -compact
438.It Dv TLS_READ_AGAIN 438.It Dv TLS_WANT_POLLIN
439A read operation is necessary to continue. 439A read operation is necessary to continue.
440.It Dv TLS_WRITE_AGAIN 440.It Dv TLS_WANT_POLLOUT
441A write operation is necessary to continue. 441A write operation is necessary to continue.
442.El 442.El
443.Pp 443.Pp
444There are underlying TLS engine read or write operations which may 444There are underlying TLS engine read or write operations which may
445not correspond with the name of the function called. 445not correspond with the name of the function called.
446For example, it is possible to receive a 446For example, it is possible to receive a
447.Dv TLS_READ_AGAIN 447.Dv TLS_WANT_POLLIN
448even when calling 448even when calling
449.Fn tls_write . 449.Fn tls_write .
450.Pp 450.Pp