From c6be0aa8ac3c172ad998ce33f392143312bfe760 Mon Sep 17 00:00:00 2001 From: Tomas Mraz Date: Tue, 20 Sep 2022 16:48:59 +0200 Subject: [PATCH] Maximum return value of BIO_ctrl_(w)pending is SIZE_MAX Reviewed-by: Hugo Landau Reviewed-by: Matt Caswell Reviewed-by: Paul Dale (Merged from https://github.com/openssl/openssl/pull/19240) --- crypto/bio/bio_lib.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/crypto/bio/bio_lib.c b/crypto/bio/bio_lib.c index 8a8c1f34f72..1a76c054d46 100644 --- a/crypto/bio/bio_lib.c +++ b/crypto/bio/bio_lib.c @@ -12,6 +12,7 @@ #include #include #include +#include "internal/numbers.h" #include "bio_local.h" /* @@ -718,6 +719,10 @@ size_t BIO_ctrl_pending(BIO *bio) if (ret < 0) ret = 0; +#if LONG_MAX > SIZE_MAX + if (ret > SIZE_MAX) + ret = SIZE_MAX; +#endif return (size_t)ret; } @@ -727,6 +732,10 @@ size_t BIO_ctrl_wpending(BIO *bio) if (ret < 0) ret = 0; +#if LONG_MAX > SIZE_MAX + if (ret > SIZE_MAX) + ret = SIZE_MAX; +#endif return (size_t)ret; } -- 2.47.3