aboutsummaryrefslogtreecommitdiff
path: root/crypto/evp/bio_ok.c
diff options
context:
space:
mode:
authorEnji Cooper <ngie@FreeBSD.org>2025-09-30 19:12:11 +0000
committerEnji Cooper <ngie@FreeBSD.org>2025-09-30 19:13:17 +0000
commit8e12a5c4eb3507846b507d0afe87d115af41df40 (patch)
tree2f170ce535a803881e0df7dd2ab3e7ccb5fac99d /crypto/evp/bio_ok.c
parentaed904c48f330dc76da942a8ee2d6eef9d11f572 (diff)
This change adds OpenSSL 3.5.4 from upstream [1]. The 3.5.4 artifact was been verified via PGP key [2] and by SHA256 checksum [3]. This is a security release, but also contains several bugfixes. More information about the release (from a high level) can be found in the release notes [4]. 1. https://github.com/openssl/openssl/releases/download/openssl-3.5.4/openssl-3.5.4.tar.gz 2. https://github.com/openssl/openssl/releases/download/openssl-3.5.4/openssl-3.5.4.tar.gz.asc 3. https://github.com/openssl/openssl/releases/download/openssl-3.5.4/openssl-3.5.4.tar.gz.sha256 4. https://github.com/openssl/openssl/blob/openssl-3.5.4/NEWS.md
Diffstat (limited to 'crypto/evp/bio_ok.c')
-rw-r--r--crypto/evp/bio_ok.c27
1 files changed, 15 insertions, 12 deletions
diff --git a/crypto/evp/bio_ok.c b/crypto/evp/bio_ok.c
index 20811ffded6f..d7f6c71ee1ad 100644
--- a/crypto/evp/bio_ok.c
+++ b/crypto/evp/bio_ok.c
@@ -1,5 +1,5 @@
/*
- * Copyright 1995-2024 The OpenSSL Project Authors. All Rights Reserved.
+ * Copyright 1995-2025 The OpenSSL Project Authors. All Rights Reserved.
*
* Licensed under the Apache License 2.0 (the "License"). You may not use
* this file except in compliance with the License. You can obtain a copy
@@ -560,7 +560,7 @@ static int block_in(BIO *b)
{
BIO_OK_CTX *ctx;
EVP_MD_CTX *md;
- unsigned long tl = 0;
+ size_t tl = 0;
unsigned char tmp[EVP_MAX_MD_SIZE];
int md_size;
@@ -571,15 +571,18 @@ static int block_in(BIO *b)
goto berr;
assert(sizeof(tl) >= OK_BLOCK_BLOCK); /* always true */
- tl = ctx->buf[0];
- tl <<= 8;
- tl |= ctx->buf[1];
- tl <<= 8;
- tl |= ctx->buf[2];
- tl <<= 8;
- tl |= ctx->buf[3];
-
- if (ctx->buf_len < tl + OK_BLOCK_BLOCK + md_size)
+ tl = ((size_t)ctx->buf[0] << 24)
+ | ((size_t)ctx->buf[1] << 16)
+ | ((size_t)ctx->buf[2] << 8)
+ | ((size_t)ctx->buf[3]);
+
+ if (tl > OK_BLOCK_SIZE)
+ goto berr;
+
+ if (tl > SIZE_MAX - OK_BLOCK_BLOCK - (size_t)md_size)
+ goto berr;
+
+ if (ctx->buf_len < tl + OK_BLOCK_BLOCK + (size_t)md_size)
return 1;
if (!EVP_DigestUpdate(md,
@@ -587,7 +590,7 @@ static int block_in(BIO *b)
goto berr;
if (!EVP_DigestFinal_ex(md, tmp, NULL))
goto berr;
- if (memcmp(&(ctx->buf[tl + OK_BLOCK_BLOCK]), tmp, md_size) == 0) {
+ if (memcmp(&(ctx->buf[tl + OK_BLOCK_BLOCK]), tmp, (size_t)md_size) == 0) {
/* there might be parts from next block lurking around ! */
ctx->buf_off_save = tl + OK_BLOCK_BLOCK + md_size;
ctx->buf_len_save = ctx->buf_len;