[openssl-commits] [openssl] master update

Dr. Stephen Henson steve at openssl.org
Mon May 4 12:06:45 UTC 2015


The branch master has been updated
       via  b8cba00807e6dd766b7bcdd3656e250e05dbe56f (commit)
       via  bdcb1a2cf553166edec0509f4bf3cd36fc964024 (commit)
      from  59ef580a14a526f6dd8d86b632d67022976fabcd (commit)


- Log -----------------------------------------------------------------
commit b8cba00807e6dd766b7bcdd3656e250e05dbe56f
Author: Dr. Stephen Henson <steve at openssl.org>
Date:   Mon May 4 00:59:48 2015 +0100

    Return an error in ASN1_TYPE_unpack_sequence if argument is NULL
    
    Thanks to Brian Carpenter for reporting this issue.
    
    Reviewed-by: Richard Levitte <levitte at openssl.org>

commit bdcb1a2cf553166edec0509f4bf3cd36fc964024
Author: Dr. Stephen Henson <steve at openssl.org>
Date:   Sun May 3 17:32:05 2015 +0100

    more OSSL_NELEM cases
    
    Reviewed-by: Tim Hudson <tjh at openssl.org>

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

Summary of changes:
 apps/apps.c               | 2 +-
 apps/ca.c                 | 2 +-
 apps/speed.c              | 2 +-
 crypto/asn1/a_type.c      | 2 +-
 crypto/cryptlib.c         | 4 ++--
 crypto/x509v3/ext_dat.h   | 2 +-
 test/constant_time_test.c | 8 ++++----
 test/dhtest.c             | 2 +-
 test/ectest.c             | 4 +---
 test/gost2814789test.c    | 3 ++-
 test/igetest.c            | 8 +++-----
 test/testutil.c           | 3 ++-
 12 files changed, 20 insertions(+), 22 deletions(-)

diff --git a/apps/apps.c b/apps/apps.c
index 1b76dbf..1e2970a 100644
--- a/apps/apps.c
+++ b/apps/apps.c
@@ -2654,7 +2654,7 @@ int app_isdir(const char *name)
 # if defined(UNICODE) || defined(_UNICODE)
     size_t i, len_0 = strlen(name) + 1;
 
-    if (len_0 > sizeof(FileData.cFileName) / sizeof(FileData.cFileName[0]))
+    if (len_0 > OSSL_NELEM(FileData.cFileName))
         return -1;
 
 #  if !defined(_WIN32_WCE) || _WIN32_WCE>=101
diff --git a/apps/ca.c b/apps/ca.c
index 0b92872..2f43a9b 100644
--- a/apps/ca.c
+++ b/apps/ca.c
@@ -2408,7 +2408,7 @@ static const char *crl_reasons[] = {
     "CAkeyTime"
 };
 
-#define NUM_REASONS (sizeof(crl_reasons) / sizeof(char *))
+#define NUM_REASONS OSSL_NELEM(crl_reasons)
 
 /*
  * Given revocation information convert to a DB string. The format of the
diff --git a/apps/speed.c b/apps/speed.c
index a5bd265..7a69485 100644
--- a/apps/speed.c
+++ b/apps/speed.c
@@ -2438,7 +2438,7 @@ static void multiblock_speed(const EVP_CIPHER *evp_cipher)
 {
     static int mblengths[] =
         { 8 * 1024, 2 * 8 * 1024, 4 * 8 * 1024, 8 * 8 * 1024, 8 * 16 * 1024 };
-    int j, count, num = sizeof(lengths) / sizeof(lengths[0]);
+    int j, count, num = OSSL_NELEM(lengths);
     const char *alg_name;
     unsigned char *inp, *out, no_key[32], no_iv[16];
     EVP_CIPHER_CTX ctx;
diff --git a/crypto/asn1/a_type.c b/crypto/asn1/a_type.c
index 864ebec..283baaa 100644
--- a/crypto/asn1/a_type.c
+++ b/crypto/asn1/a_type.c
@@ -179,7 +179,7 @@ ASN1_TYPE *ASN1_TYPE_pack_sequence(const ASN1_ITEM *it, void *s, ASN1_TYPE **t)
 
 void *ASN1_TYPE_unpack_sequence(const ASN1_ITEM *it, const ASN1_TYPE *t)
 {
-    if (t->type != V_ASN1_SEQUENCE || t->value.sequence == NULL)
+    if (t == NULL || t->type != V_ASN1_SEQUENCE || t->value.sequence == NULL)
         return NULL;
     return ASN1_item_unpack(t->value.sequence, it);
 }
diff --git a/crypto/cryptlib.c b/crypto/cryptlib.c
index be4cdb0..3742ff2 100644
--- a/crypto/cryptlib.c
+++ b/crypto/cryptlib.c
@@ -406,8 +406,8 @@ void OPENSSL_showfatal(const char *fmta, ...)
         } while (0);
 
     va_start(ap, fmta);
-    _vsntprintf(buf, sizeof(buf) / sizeof(TCHAR) - 1, fmt, ap);
-    buf[sizeof(buf) / sizeof(TCHAR) - 1] = _T('\0');
+    _vsntprintf(buf, OSSL_NELEM(buf) - 1, fmt, ap);
+    buf[OSSL_NELEM(buf) - 1] = _T('\0');
     va_end(ap);
 
 # if defined(_WIN32_WINNT) && _WIN32_WINNT>=0x0333
diff --git a/crypto/x509v3/ext_dat.h b/crypto/x509v3/ext_dat.h
index 4e0fe92..d43c86c 100644
--- a/crypto/x509v3/ext_dat.h
+++ b/crypto/x509v3/ext_dat.h
@@ -131,4 +131,4 @@ static const X509V3_EXT_METHOD *standard_exts[] = {
 
 /* Number of standard extensions */
 
-#define STANDARD_EXTENSION_COUNT (sizeof(standard_exts)/sizeof(X509V3_EXT_METHOD *))
+#define STANDARD_EXTENSION_COUNT OSSL_NELEM(standard_exts)
diff --git a/test/constant_time_test.c b/test/constant_time_test.c
index d313d0c..bdb2702 100644
--- a/test/constant_time_test.c
+++ b/test/constant_time_test.c
@@ -231,12 +231,12 @@ int main(int argc, char *argv[])
     int num_failed = 0, num_all = 0;
     fprintf(stdout, "Testing constant time operations...\n");
 
-    for (i = 0; i < sizeof(test_values) / sizeof(int); ++i) {
+    for (i = 0; i < OSSL_NELEM(test_values); ++i) {
         a = test_values[i];
         num_failed += test_is_zero(a);
         num_failed += test_is_zero_8(a);
         num_all += 2;
-        for (j = 0; j < sizeof(test_values) / sizeof(int); ++j) {
+        for (j = 0; j < OSSL_NELEM(test_values); ++j) {
             b = test_values[j];
             num_failed += test_binary_op(&constant_time_lt,
                                          "constant_time_lt", a, b, a < b);
@@ -274,9 +274,9 @@ int main(int argc, char *argv[])
         }
     }
 
-    for (i = 0; i < sizeof(signed_test_values) / sizeof(int); ++i) {
+    for (i = 0; i < OSSL_NELEM(signed_test_values); ++i) {
         c = signed_test_values[i];
-        for (j = 0; j < sizeof(signed_test_values) / sizeof(int); ++j) {
+        for (j = 0; j < OSSL_NELEM(signed_test_values); ++j) {
             d = signed_test_values[j];
             num_failed += test_select_int(c, d);
             num_failed += test_eq_int(c, d);
diff --git a/test/dhtest.c b/test/dhtest.c
index 621fcba..7e46166 100644
--- a/test/dhtest.c
+++ b/test/dhtest.c
@@ -485,7 +485,7 @@ static const rfc5114_td rfctd[] = {
 static int run_rfc5114_tests(void)
 {
     int i;
-    for (i = 0; i < (int)(sizeof(rfctd) / sizeof(rfc5114_td)); i++) {
+    for (i = 0; i < (int)OSSL_NELEM(rfctd); i++) {
         DH *dhA, *dhB;
         unsigned char *Z1 = NULL, *Z2 = NULL;
         const rfc5114_td *td = rfctd + i;
diff --git a/test/ectest.c b/test/ectest.c
index 7320d3d..4b15708 100644
--- a/test/ectest.c
+++ b/test/ectest.c
@@ -1628,9 +1628,7 @@ static void nistp_tests()
 {
     unsigned i;
 
-    for (i = 0;
-         i < sizeof(nistp_tests_params) / sizeof(struct nistp_test_params);
-         i++) {
+    for (i = 0; i < OSSL_NELEM(nistp_tests_params); i++) {
         nistp_single_test(&nistp_tests_params[i]);
     }
 }
diff --git a/test/gost2814789test.c b/test/gost2814789test.c
index 8384d66..4569249 100644
--- a/test/gost2814789test.c
+++ b/test/gost2814789test.c
@@ -26,6 +26,7 @@ int main(int argc, char *argv[])
 # include <openssl/evp.h>
 # include <openssl/hmac.h>
 # include <openssl/obj_mac.h>
+# include "e_os.h"
 
 # define CCGOST_ID "gost"
 
@@ -1311,7 +1312,7 @@ int main(int argc, char *argv[])
     }
 
     /* Test cases */
-    for (t = 0; t < sizeof(tcs) / sizeof(tcs[0]); t++) {
+    for (t = 0; t < OSSL_NELEM(tcs); t++) {
         if (NULL == tcs[t].szDerive) {
             continue;
         }
diff --git a/test/igetest.c b/test/igetest.c
index 96e9884..9c80c85 100644
--- a/test/igetest.c
+++ b/test/igetest.c
@@ -55,6 +55,7 @@
 #include <stdio.h>
 #include <string.h>
 #include <assert.h>
+#include "e_os.h"
 
 #define TEST_SIZE       128
 #define BIG_TEST_SIZE 10240
@@ -191,8 +192,7 @@ static int run_test_vectors(void)
     unsigned int n;
     int errs = 0;
 
-    for (n = 0; n < sizeof(ige_test_vectors) / sizeof(ige_test_vectors[0]);
-         ++n) {
+    for (n = 0; n < OSSL_NELEM(ige_test_vectors); ++n) {
         const struct ige_test *const v = &ige_test_vectors[n];
         AES_KEY key;
         unsigned char buf[MAX_VECTOR_SIZE];
@@ -235,9 +235,7 @@ static int run_test_vectors(void)
         }
     }
 
-    for (n = 0;
-         n < sizeof(bi_ige_test_vectors) / sizeof(bi_ige_test_vectors[0]);
-         ++n) {
+    for (n = 0; n < OSSL_NELEM(bi_ige_test_vectors); ++n) {
         const struct bi_ige_test *const v = &bi_ige_test_vectors[n];
         AES_KEY key1;
         AES_KEY key2;
diff --git a/test/testutil.c b/test/testutil.c
index 05ed589..70087d3 100644
--- a/test/testutil.c
+++ b/test/testutil.c
@@ -61,6 +61,7 @@
 #include <assert.h>
 #include <stdlib.h>
 #include <stdio.h>
+#include "e_os.h"
 
 /*
  * Declares the structures needed to register each test case function.
@@ -75,7 +76,7 @@ static int num_tests = 0;
 
 void add_test(const char *test_case_name, int (*test_fn) ())
 {
-    assert(num_tests != (sizeof(all_tests) / sizeof(all_tests)[0]));
+    assert(num_tests != OSSL_NELEM(all_tests));
     all_tests[num_tests].test_case_name = test_case_name;
     all_tests[num_tests].test_fn = test_fn;
     ++num_tests;


More information about the openssl-commits mailing list