Adding ARRAY_SIZE macro for getting the size of constant arrays.
Change-Id: Ie60744761f5aa434a71a998f5ca98a8f8b1c25d5
Reviewed-on: https://boringssl-review.googlesource.com/10447
Reviewed-by: David Benjamin <davidben@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
diff --git a/ssl/t1_lib.c b/ssl/t1_lib.c
index a9a8fa3..496c9c4 100644
--- a/ssl/t1_lib.c
+++ b/ssl/t1_lib.c
@@ -124,6 +124,7 @@
#include <openssl/type_check.h>
#include "internal.h"
+#include "../crypto/internal.h"
static int ssl_check_clienthello_tlsext(SSL *ssl);
@@ -327,7 +328,7 @@
*out_group_ids_len = ssl->supported_group_list_len;
if (!*out_group_ids) {
*out_group_ids = kDefaultGroups;
- *out_group_ids_len = sizeof(kDefaultGroups) / sizeof(kDefaultGroups[0]);
+ *out_group_ids_len = OPENSSL_ARRAY_SIZE(kDefaultGroups);
}
}
@@ -559,13 +560,11 @@
* https://bugzilla.mozilla.org/show_bug.cgi?id=1119983 */
if (max_version >= TLS1_3_VERSION) {
*psigs = kDefaultTLS13SignatureAlgorithms;
- return sizeof(kDefaultTLS13SignatureAlgorithms) /
- sizeof(kDefaultTLS13SignatureAlgorithms[0]);
+ return OPENSSL_ARRAY_SIZE(kDefaultTLS13SignatureAlgorithms);
}
*psigs = kDefaultSignatureAlgorithms;
- return sizeof(kDefaultSignatureAlgorithms) /
- sizeof(kDefaultSignatureAlgorithms[0]);
+ return OPENSSL_ARRAY_SIZE(kDefaultSignatureAlgorithms);
}
int tls12_check_peer_sigalg(SSL *ssl, int *out_alert, uint16_t sigalg) {
@@ -3076,8 +3075,7 @@
static const uint16_t kDefaultPeerAlgorithms[] = {SSL_SIGN_RSA_PKCS1_SHA1,
SSL_SIGN_ECDSA_SHA1};
peer_sigalgs = kDefaultPeerAlgorithms;
- peer_sigalgs_len =
- sizeof(kDefaultPeerAlgorithms) / sizeof(kDefaultPeerAlgorithms[0]);
+ peer_sigalgs_len = OPENSSL_ARRAY_SIZE(kDefaultPeerAlgorithms);
}
for (i = 0; i < sigalgs_len; i++) {