diff options
| author | jsing <> | 2019-02-28 17:44:56 +0000 |
|---|---|---|
| committer | jsing <> | 2019-02-28 17:44:56 +0000 |
| commit | d6d5d2b831019a438c6d7b9f6c231d424e049fc6 (patch) | |
| tree | 05a9ce959a1192d122f2636b0ccc18d8852a0492 /src/lib/libssl/tls13_lib.c | |
| parent | 3625add9e1a709467128c0aa66097091f869467e (diff) | |
| download | openbsd-d6d5d2b831019a438c6d7b9f6c231d424e049fc6.tar.gz openbsd-d6d5d2b831019a438c6d7b9f6c231d424e049fc6.tar.bz2 openbsd-d6d5d2b831019a438c6d7b9f6c231d424e049fc6.zip | |
Add appropriate length checks to tls13_legacy_{read,write}_bytes()
ok inoguchi@ tb@
Diffstat (limited to '')
| -rw-r--r-- | src/lib/libssl/tls13_lib.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/src/lib/libssl/tls13_lib.c b/src/lib/libssl/tls13_lib.c index 0151395be8..e371d71750 100644 --- a/src/lib/libssl/tls13_lib.c +++ b/src/lib/libssl/tls13_lib.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: tls13_lib.c,v 1.6 2019/02/26 17:36:30 jsing Exp $ */ | 1 | /* $OpenBSD: tls13_lib.c,v 1.7 2019/02/28 17:44:56 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 | * |
| @@ -251,9 +251,12 @@ tls13_legacy_read_bytes(SSL *ssl, int type, unsigned char *buf, int len, int pee | |||
| 251 | SSLerror(ssl, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED); | 251 | SSLerror(ssl, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED); |
| 252 | return -1; | 252 | return -1; |
| 253 | } | 253 | } |
| 254 | if (len < 0) { | ||
| 255 | SSLerror(ssl, SSL_R_BAD_LENGTH); | ||
| 256 | return -1; | ||
| 257 | } | ||
| 254 | 258 | ||
| 255 | ret = tls13_read_application_data(ctx->rl, buf, len); | 259 | ret = tls13_read_application_data(ctx->rl, buf, len); |
| 256 | |||
| 257 | return tls13_legacy_return_code(ssl, ret); | 260 | return tls13_legacy_return_code(ssl, ret); |
| 258 | } | 261 | } |
| 259 | 262 | ||
| @@ -267,8 +270,11 @@ tls13_legacy_write_bytes(SSL *ssl, int type, const void *buf, int len) | |||
| 267 | SSLerror(ssl, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED); | 270 | SSLerror(ssl, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED); |
| 268 | return -1; | 271 | return -1; |
| 269 | } | 272 | } |
| 273 | if (len <= 0) { | ||
| 274 | SSLerror(ssl, SSL_R_BAD_LENGTH); | ||
| 275 | return -1; | ||
| 276 | } | ||
| 270 | 277 | ||
| 271 | ret = tls13_write_application_data(ctx->rl, buf, len); | 278 | ret = tls13_write_application_data(ctx->rl, buf, len); |
| 272 | |||
| 273 | return tls13_legacy_return_code(ssl, ret); | 279 | return tls13_legacy_return_code(ssl, ret); |
| 274 | } | 280 | } |
