Define STACK_OF(OPENSSL_STRING) more straight-forwardly.
This results in one change, which is the comparison function goes from:
typedef char *OPENSSL_STRING;
static int sk_strcmp(const OPENSSL_STRING *a,
const OPENSSL_STRING *b);
which is:
static int sk_strcmp(char *const *a, char *const *b)
into:
static int sk_strcmp(const char **a, const char **b)
Neither is correct (both consts should be there), but switching the
defintion is necessary to attach the 'const' to 'char' itself. Otherwise
it wouldn't see through the typedef. Fixing the rest of the calling
convention will finish the job. Plan there is, when
I00d13c949a535c0d60873fe4ba2e5604bb585cca lands, I'll switch Envoy to
call that. Then we should be clear to const-correct the callback.
(While STACK_OF(OPENSSL_STRING) is used externally, nothing external
touches the comparison function.)
Bug: 498
Change-Id: I77bdf2a72b2553bf9409a1d39326890ed5c3582c
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/53008
Reviewed-by: Adam Langley <agl@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
diff --git a/crypto/x509v3/v3_utl.c b/crypto/x509v3/v3_utl.c
index 064e71b..bf5ef52 100644
--- a/crypto/x509v3/v3_utl.c
+++ b/crypto/x509v3/v3_utl.c
@@ -76,7 +76,7 @@
static char *strip_spaces(char *name);
-static int sk_strcmp(const OPENSSL_STRING *a, const OPENSSL_STRING *b);
+static int sk_strcmp(const char **a, const char **b);
static STACK_OF(OPENSSL_STRING) *get_email(X509_NAME *name,
GENERAL_NAMES *gens);
static void str_free(OPENSSL_STRING str);
@@ -572,7 +572,7 @@
return 1;
}
-static int sk_strcmp(const OPENSSL_STRING *a, const OPENSSL_STRING *b)
+static int sk_strcmp(const char **a, const char **b)
{
return strcmp(*a, *b);
}
diff --git a/include/openssl/stack.h b/include/openssl/stack.h
index 8740367..7b95f34 100644
--- a/include/openssl/stack.h
+++ b/include/openssl/stack.h
@@ -437,18 +437,10 @@
BORINGSSL_DEFINE_STACK_OF_IMPL(type, const type *, const type *) \
BORINGSSL_DEFINE_STACK_TRAITS(type, const type, true)
-// DEFINE_SPECIAL_STACK_OF defines |STACK_OF(type)| to be a stack whose elements
-// are |type|, where |type| must be a typedef for a pointer.
-#define DEFINE_SPECIAL_STACK_OF(type) \
- OPENSSL_STATIC_ASSERT(sizeof(type) == sizeof(void *), \
- #type " is not a pointer"); \
- BORINGSSL_DEFINE_STACK_OF_IMPL(type, type, const type)
-
-
typedef char *OPENSSL_STRING;
DEFINE_STACK_OF(void)
-DEFINE_SPECIAL_STACK_OF(OPENSSL_STRING)
+DEFINE_NAMED_STACK_OF(OPENSSL_STRING, char)
#if defined(__cplusplus)