summaryrefslogtreecommitdiffstats
path: root/lib/libssl/tls13_record_layer.c
diff options
context:
space:
mode:
authorjsing <jsing@openbsd.org>2019-02-25 16:52:34 +0000
committerjsing <jsing@openbsd.org>2019-02-25 16:52:34 +0000
commit19110973213659433031df831e87acb2010c33c8 (patch)
tree0255658ec818f3bfabce7c7800cfd05805d0a14f /lib/libssl/tls13_record_layer.c
parentAdd a handshake action sent handler and use it for client finished. (diff)
downloadwireguard-openbsd-19110973213659433031df831e87acb2010c33c8.tar.xz
wireguard-openbsd-19110973213659433031df831e87acb2010c33c8.zip
Correctly handle oversize writes.
If the record layer is asked to write more than fits in a plaintext record, cap the amount at that limit. This means that we will effectively write out a single record and return a short-write. This behaviour matches SSL_write() with SSL_MODE_ENABLE_PARTIAL_WRITE enabled and the non-SSL_MODE_ENABLE_PARTIAL_WRITE case will be handled at a higher layer. ok inoguchi@ tb@
Diffstat (limited to 'lib/libssl/tls13_record_layer.c')
-rw-r--r--lib/libssl/tls13_record_layer.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/libssl/tls13_record_layer.c b/lib/libssl/tls13_record_layer.c
index 07efcbc7021..d4bc50ab4e1 100644
--- a/lib/libssl/tls13_record_layer.c
+++ b/lib/libssl/tls13_record_layer.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: tls13_record_layer.c,v 1.6 2019/02/23 15:02:34 jsing Exp $ */
+/* $OpenBSD: tls13_record_layer.c,v 1.7 2019/02/25 16:52:34 jsing Exp $ */
/*
* Copyright (c) 2018, 2019 Joel Sing <jsing@openbsd.org>
*
@@ -760,7 +760,9 @@ static ssize_t
tls13_record_layer_write(struct tls13_record_layer *rl, uint8_t content_type,
const uint8_t *buf, size_t n)
{
- /* XXX - handle fragmenting... */
+ if (n > TLS13_RECORD_MAX_PLAINTEXT_LEN)
+ n = TLS13_RECORD_MAX_PLAINTEXT_LEN;
+
return tls13_record_layer_write_record(rl, content_type, buf, n);
}