Maximum return value of BIO_ctrl_(w)pending is SIZE_MAX
[openssl.git] / crypto / bio / bio_lib.c
index 8a8c1f34f72deb54a2776d5abc487b85bb4d7d0a..1a76c054d468aa4c37bbf9709314b65fa87d0c74 100644 (file)
@@ -12,6 +12,7 @@
 #include <stdio.h>
 #include <errno.h>
 #include <openssl/crypto.h>
+#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;
 }