diff options
author | jsing <> | 2022-02-06 16:08:14 +0000 |
---|---|---|
committer | jsing <> | 2022-02-06 16:08:14 +0000 |
commit | fde80c97b7537c9c34662547ba47a934cb8bab59 (patch) | |
tree | 46170269eda20612e21905576d09ac081e9a0e41 /src | |
parent | 99b7f379918f04971fa967c83af3373791c4803d (diff) | |
download | openbsd-fde80c97b7537c9c34662547ba47a934cb8bab59.tar.gz openbsd-fde80c97b7537c9c34662547ba47a934cb8bab59.tar.bz2 openbsd-fde80c97b7537c9c34662547ba47a934cb8bab59.zip |
Handle zero byte reads/writes that trigger handshakes in the TLSv1.3 stack.
With the legaacy stack, it is possible to do a zero byte SSL_read() or
SSL_write() that triggers the handshake, but then returns zero without
SSL_ERROR_WANT_READ or SSL_ERROR_WANT_WRITE being flagged. This currently
works in the TLSv1.3 stack by returning TLS_IO_WANT_POLLIN or
TLS_IO_WANT_POLLOUT, which is then hidden by SSL_get_error().
However, due to upcoming changes to SSL_get_error() this will no longer be
the case. In order to maintain the existing legacy behaviour, explicitly
handle zero byte reads and writes in the TLSv1.3 stack, following
completion of a handshake.
ok inoguchi@ tb@
Diffstat (limited to 'src')
-rw-r--r-- | src/lib/libssl/tls13_legacy.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/lib/libssl/tls13_legacy.c b/src/lib/libssl/tls13_legacy.c index 0379c978e9..27e030fa77 100644 --- a/src/lib/libssl/tls13_legacy.c +++ b/src/lib/libssl/tls13_legacy.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: tls13_legacy.c,v 1.36 2022/02/05 14:54:10 jsing Exp $ */ | 1 | /* $OpenBSD: tls13_legacy.c,v 1.37 2022/02/06 16:08:14 jsing Exp $ */ |
2 | /* | 2 | /* |
3 | * Copyright (c) 2018, 2019 Joel Sing <jsing@openbsd.org> | 3 | * Copyright (c) 2018, 2019 Joel Sing <jsing@openbsd.org> |
4 | * | 4 | * |
@@ -229,6 +229,8 @@ tls13_legacy_read_bytes(SSL *ssl, int type, unsigned char *buf, int len, int pee | |||
229 | if (ctx == NULL || !ctx->handshake_completed) { | 229 | if (ctx == NULL || !ctx->handshake_completed) { |
230 | if ((ret = ssl->internal->handshake_func(ssl)) <= 0) | 230 | if ((ret = ssl->internal->handshake_func(ssl)) <= 0) |
231 | return ret; | 231 | return ret; |
232 | if (len == 0) | ||
233 | return 0; | ||
232 | return tls13_legacy_return_code(ssl, TLS13_IO_WANT_POLLIN); | 234 | return tls13_legacy_return_code(ssl, TLS13_IO_WANT_POLLIN); |
233 | } | 235 | } |
234 | 236 | ||
@@ -263,6 +265,8 @@ tls13_legacy_write_bytes(SSL *ssl, int type, const void *vbuf, int len) | |||
263 | if (ctx == NULL || !ctx->handshake_completed) { | 265 | if (ctx == NULL || !ctx->handshake_completed) { |
264 | if ((ret = ssl->internal->handshake_func(ssl)) <= 0) | 266 | if ((ret = ssl->internal->handshake_func(ssl)) <= 0) |
265 | return ret; | 267 | return ret; |
268 | if (len == 0) | ||
269 | return 0; | ||
266 | return tls13_legacy_return_code(ssl, TLS13_IO_WANT_POLLOUT); | 270 | return tls13_legacy_return_code(ssl, TLS13_IO_WANT_POLLOUT); |
267 | } | 271 | } |
268 | 272 | ||