From: Tomas Mraz Date: Tue, 20 Sep 2022 14:48:59 +0000 (+0200) Subject: Maximum return value of BIO_ctrl_(w)pending is SIZE_MAX X-Git-Tag: openssl-3.2.0-alpha1~2042 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c6be0aa8ac3c172ad998ce33f392143312bfe760;p=thirdparty%2Fopenssl.git 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) --- 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; }