[openssl] master update

Dr. Paul Dale pauli at openssl.org
Tue Jul 6 08:44:18 UTC 2021


The branch master has been updated
       via  ef1e0242a9aec5210845df86162c0b9219ff0f11 (commit)
      from  4e20d04ee0e7be2061c1e5d2c2c8d714b7923c89 (commit)


- Log -----------------------------------------------------------------
commit ef1e0242a9aec5210845df86162c0b9219ff0f11
Author: Pauli <pauli at openssl.org>
Date:   Sat Jun 19 09:54:55 2021 +1000

    test: add some integral type size sanity checks
    
    With the recent problem on VMS of maxint_t being defined as a 32 bit integer
    despite OpenSSL mandating 64 bit integers being available, it seems prudent
    to add some sanity checks for out integral types.
    
    Reviewed-by: Tomas Mraz <tomas at openssl.org>
    (Merged from https://github.com/openssl/openssl/pull/15830)

-----------------------------------------------------------------------

Summary of changes:
 test/sanitytest.c | 35 ++++++++++++++++++++++++++++++++++-
 1 file changed, 34 insertions(+), 1 deletion(-)

diff --git a/test/sanitytest.c b/test/sanitytest.c
index 46cd224e7a..892b3b55e1 100644
--- a/test/sanitytest.c
+++ b/test/sanitytest.c
@@ -8,6 +8,7 @@
  */
 
 #include <string.h>
+#include <openssl/types.h>
 #include "testutil.h"
 #include "internal/numbers.h"
 
@@ -76,6 +77,38 @@ static int test_sanity_unsigned_conversion(void)
 
 static int test_sanity_range(void)
 {
+    /* Verify some types are the correct size */
+    if (!TEST_size_t_eq(sizeof(int8_t), 1)
+            || !TEST_size_t_eq(sizeof(uint8_t), 1)
+            || !TEST_size_t_eq(sizeof(int16_t), 2)
+            || !TEST_size_t_eq(sizeof(uint16_t), 2)
+            || !TEST_size_t_eq(sizeof(int32_t), 4)
+            || !TEST_size_t_eq(sizeof(uint32_t), 4)
+            || !TEST_size_t_eq(sizeof(int64_t), 8)
+            || !TEST_size_t_eq(sizeof(uint64_t), 8)
+#ifdef UINT128_MAX
+            || !TEST_size_t_eq(sizeof(int128_t), 16)
+            || !TEST_size_t_eq(sizeof(uint128_t), 16)
+#endif
+            || !TEST_size_t_eq(sizeof(char), 1)
+            || !TEST_size_t_eq(sizeof(unsigned char), 1))
+        return 0;
+
+    /* We want our long longs to be at least 64 bits */
+    if (!TEST_size_t_ge(sizeof(long long int), 8)
+            || !TEST_size_t_ge(sizeof(unsigned long long int), 8))
+        return 0;
+
+    /*
+     * Verify intmax_t.
+     * Some platforms defined intmax_t to be 64 bits but still support
+     * an int128_t, so this check is for at least 64 bits.
+     */
+    if (!TEST_size_t_ge(sizeof(ossl_intmax_t), 8)
+            || !TEST_size_t_ge(sizeof(ossl_uintmax_t), 8)
+            || !TEST_size_t_ge(sizeof(ossl_uintmax_t), sizeof(size_t)))
+        return 0;
+
     /* This isn't possible to check using the framework functions */
     if (SIZE_MAX < INT_MAX) {
         TEST_error("int must not be wider than size_t");
@@ -86,7 +119,7 @@ static int test_sanity_range(void)
 
 static int test_sanity_memcmp(void)
 {
-    return CRYPTO_memcmp("ab","cd",2);
+    return CRYPTO_memcmp("ab", "cd", 2);
 }
 
 int setup_tests(void)


More information about the openssl-commits mailing list