summaryrefslogtreecommitdiffstats
path: root/lib/libssl/tls13_lib.c
diff options
context:
space:
mode:
authorjsing <jsing@openbsd.org>2019-02-28 17:44:56 +0000
committerjsing <jsing@openbsd.org>2019-02-28 17:44:56 +0000
commit0d87fd2af5bef833900e4e05de2bc454b6b6dd1a (patch)
tree12f7e249b10343918e432b30cad5ae704a078fee /lib/libssl/tls13_lib.c
parentRemove unused record_type from TLSv1.3 handshake actions. (diff)
downloadwireguard-openbsd-0d87fd2af5bef833900e4e05de2bc454b6b6dd1a.tar.xz
wireguard-openbsd-0d87fd2af5bef833900e4e05de2bc454b6b6dd1a.zip
Add appropriate length checks to tls13_legacy_{read,write}_bytes()
ok inoguchi@ tb@
Diffstat (limited to 'lib/libssl/tls13_lib.c')
-rw-r--r--lib/libssl/tls13_lib.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/lib/libssl/tls13_lib.c b/lib/libssl/tls13_lib.c
index 0151395be81..e371d717506 100644
--- a/lib/libssl/tls13_lib.c
+++ b/lib/libssl/tls13_lib.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: tls13_lib.c,v 1.6 2019/02/26 17:36:30 jsing Exp $ */
+/* $OpenBSD: tls13_lib.c,v 1.7 2019/02/28 17:44:56 jsing Exp $ */
/*
* Copyright (c) 2018, 2019 Joel Sing <jsing@openbsd.org>
*
@@ -251,9 +251,12 @@ tls13_legacy_read_bytes(SSL *ssl, int type, unsigned char *buf, int len, int pee
SSLerror(ssl, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);
return -1;
}
+ if (len < 0) {
+ SSLerror(ssl, SSL_R_BAD_LENGTH);
+ return -1;
+ }
ret = tls13_read_application_data(ctx->rl, buf, len);
-
return tls13_legacy_return_code(ssl, ret);
}
@@ -267,8 +270,11 @@ tls13_legacy_write_bytes(SSL *ssl, int type, const void *buf, int len)
SSLerror(ssl, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);
return -1;
}
+ if (len <= 0) {
+ SSLerror(ssl, SSL_R_BAD_LENGTH);
+ return -1;
+ }
ret = tls13_write_application_data(ctx->rl, buf, len);
-
return tls13_legacy_return_code(ssl, ret);
}