diff options
author | Dr. Stephen Henson <steve@openssl.org> | 2008-10-22 15:43:01 +0000 |
---|---|---|
committer | Dr. Stephen Henson <steve@openssl.org> | 2008-10-22 15:43:01 +0000 |
commit | e19106f5fb7da7db15449a9a50f9be9047800757 (patch) | |
tree | 0341d860168821112fb47ded07b1f761895c04cd | |
parent | ae7ec4c71de74fa52c5d89e32e28445c6602990d (diff) | |
download | openssl-new-e19106f5fb7da7db15449a9a50f9be9047800757.tar.gz |
Create function of the form OBJ_bsearch_xxx() in bsearch typesafe macros
with the appropriate parameters which calls OBJ_bsearch(). A compiler will
typically inline this.
This avoids the need for cmp_xxx variables and fixes unchecked const issues
with CHECKED_PTR_OF()
-rw-r--r-- | crypto/asn1/a_strnid.c | 10 | ||||
-rw-r--r-- | crypto/asn1/ameth_lib.c | 10 | ||||
-rw-r--r-- | crypto/evp/evp_pbe.c | 12 | ||||
-rw-r--r-- | crypto/evp/pmeth_lib.c | 10 | ||||
-rw-r--r-- | crypto/objects/obj_dat.c | 21 | ||||
-rw-r--r-- | crypto/objects/obj_xref.c | 31 | ||||
-rw-r--r-- | crypto/objects/objects.h | 24 | ||||
-rw-r--r-- | crypto/x509/x509_vpm.c | 10 | ||||
-rw-r--r-- | crypto/x509v3/v3_lib.c | 8 | ||||
-rw-r--r-- | crypto/x509v3/v3_purp.c | 10 | ||||
-rw-r--r-- | ssl/s2_lib.c | 5 | ||||
-rw-r--r-- | ssl/s3_lib.c | 3 | ||||
-rw-r--r-- | ssl/ssl_locl.h | 2 |
13 files changed, 70 insertions, 86 deletions
diff --git a/crypto/asn1/a_strnid.c b/crypto/asn1/a_strnid.c index f0d5416660..cdba943737 100644 --- a/crypto/asn1/a_strnid.c +++ b/crypto/asn1/a_strnid.c @@ -185,14 +185,14 @@ static int sk_table_cmp(const ASN1_STRING_TABLE * const *a, return (*a)->nid - (*b)->nid; } -DECLARE_OBJ_BSEARCH_CMP_FN(ASN1_STRING_TABLE, ASN1_STRING_TABLE, table_cmp); +DECLARE_OBJ_BSEARCH_CMP_FN(ASN1_STRING_TABLE, ASN1_STRING_TABLE, table); static int table_cmp(const ASN1_STRING_TABLE *a, const ASN1_STRING_TABLE *b) { return a->nid - b->nid; } -IMPLEMENT_OBJ_BSEARCH_CMP_FN(ASN1_STRING_TABLE, ASN1_STRING_TABLE, table_cmp); +IMPLEMENT_OBJ_BSEARCH_CMP_FN(ASN1_STRING_TABLE, ASN1_STRING_TABLE, table); ASN1_STRING_TABLE *ASN1_STRING_TABLE_get(int nid) { @@ -200,10 +200,8 @@ ASN1_STRING_TABLE *ASN1_STRING_TABLE_get(int nid) ASN1_STRING_TABLE *ttmp; ASN1_STRING_TABLE fnd; fnd.nid = nid; - ttmp = OBJ_bsearch(ASN1_STRING_TABLE, &fnd, - ASN1_STRING_TABLE, tbl_standard, - sizeof(tbl_standard)/sizeof(ASN1_STRING_TABLE), - table_cmp); + ttmp = OBJ_bsearch_table(&fnd, tbl_standard, + sizeof(tbl_standard)/sizeof(ASN1_STRING_TABLE)); if(ttmp) return ttmp; if(!stable) return NULL; idx = sk_ASN1_STRING_TABLE_find(stable, &fnd); diff --git a/crypto/asn1/ameth_lib.c b/crypto/asn1/ameth_lib.c index fee7198b85..5063191515 100644 --- a/crypto/asn1/ameth_lib.c +++ b/crypto/asn1/ameth_lib.c @@ -113,7 +113,7 @@ void main() #endif DECLARE_OBJ_BSEARCH_CMP_FN(const EVP_PKEY_ASN1_METHOD *, - const EVP_PKEY_ASN1_METHOD *, ameth_cmp); + const EVP_PKEY_ASN1_METHOD *, ameth); static int ameth_cmp(const EVP_PKEY_ASN1_METHOD * const *a, const EVP_PKEY_ASN1_METHOD * const *b) @@ -122,7 +122,7 @@ static int ameth_cmp(const EVP_PKEY_ASN1_METHOD * const *a, } IMPLEMENT_OBJ_BSEARCH_CMP_FN(const EVP_PKEY_ASN1_METHOD *, - const EVP_PKEY_ASN1_METHOD *, ameth_cmp); + const EVP_PKEY_ASN1_METHOD *, ameth); int EVP_PKEY_asn1_get_count(void) { @@ -155,11 +155,9 @@ static const EVP_PKEY_ASN1_METHOD *pkey_asn1_find(int type) if (idx >= 0) return sk_EVP_PKEY_ASN1_METHOD_value(app_methods, idx); } - ret = OBJ_bsearch(const EVP_PKEY_ASN1_METHOD *, &t, - const EVP_PKEY_ASN1_METHOD *, standard_methods, + ret = OBJ_bsearch_ameth(&t, standard_methods, sizeof(standard_methods) - /sizeof(EVP_PKEY_ASN1_METHOD *), - ameth_cmp); + /sizeof(EVP_PKEY_ASN1_METHOD *)); if (!ret || !*ret) return NULL; return *ret; diff --git a/crypto/evp/evp_pbe.c b/crypto/evp/evp_pbe.c index 7d6a50266a..e1d72b762a 100644 --- a/crypto/evp/evp_pbe.c +++ b/crypto/evp/evp_pbe.c @@ -189,9 +189,9 @@ int EVP_PBE_CipherInit(ASN1_OBJECT *pbe_obj, const char *pass, int passlen, return 1; } -DECLARE_OBJ_BSEARCH_CMP_FN(EVP_PBE_CTL, EVP_PBE_CTL, pbe_cmp2); +DECLARE_OBJ_BSEARCH_CMP_FN(EVP_PBE_CTL, EVP_PBE_CTL, pbe2); -static int pbe_cmp2(const EVP_PBE_CTL *pbe1, const EVP_PBE_CTL *pbe2) +static int pbe2_cmp(const EVP_PBE_CTL *pbe1, const EVP_PBE_CTL *pbe2) { int ret = pbe1->pbe_type - pbe2->pbe_type; if (ret) @@ -200,7 +200,7 @@ static int pbe_cmp2(const EVP_PBE_CTL *pbe1, const EVP_PBE_CTL *pbe2) return pbe1->pbe_nid - pbe2->pbe_nid; } -IMPLEMENT_OBJ_BSEARCH_CMP_FN(EVP_PBE_CTL, EVP_PBE_CTL, pbe_cmp2); +IMPLEMENT_OBJ_BSEARCH_CMP_FN(EVP_PBE_CTL, EVP_PBE_CTL, pbe2); static int pbe_cmp(const EVP_PBE_CTL * const *a, const EVP_PBE_CTL * const *b) { @@ -271,10 +271,8 @@ int EVP_PBE_find(int type, int pbe_nid, } if (pbetmp == NULL) { - pbetmp = OBJ_bsearch(EVP_PBE_CTL, &pbelu, - EVP_PBE_CTL, builtin_pbe, - sizeof(builtin_pbe)/sizeof(EVP_PBE_CTL), - pbe_cmp2); + pbetmp = OBJ_bsearch_pbe2(&pbelu, builtin_pbe, + sizeof(builtin_pbe)/sizeof(EVP_PBE_CTL)); } if (pbetmp == NULL) return 0; diff --git a/crypto/evp/pmeth_lib.c b/crypto/evp/pmeth_lib.c index d1b661ff36..072736719d 100644 --- a/crypto/evp/pmeth_lib.c +++ b/crypto/evp/pmeth_lib.c @@ -85,7 +85,7 @@ static const EVP_PKEY_METHOD *standard_methods[] = }; DECLARE_OBJ_BSEARCH_CMP_FN(const EVP_PKEY_METHOD *, const EVP_PKEY_METHOD *, - pmeth_cmp); + pmeth); static int pmeth_cmp(const EVP_PKEY_METHOD * const *a, const EVP_PKEY_METHOD * const *b) @@ -94,7 +94,7 @@ static int pmeth_cmp(const EVP_PKEY_METHOD * const *a, } IMPLEMENT_OBJ_BSEARCH_CMP_FN(const EVP_PKEY_METHOD *, const EVP_PKEY_METHOD *, - pmeth_cmp); + pmeth); const EVP_PKEY_METHOD *EVP_PKEY_meth_find(int type) { @@ -108,10 +108,8 @@ const EVP_PKEY_METHOD *EVP_PKEY_meth_find(int type) if (idx >= 0) return sk_EVP_PKEY_METHOD_value(app_pkey_methods, idx); } - ret = OBJ_bsearch(const EVP_PKEY_METHOD *, &t, - const EVP_PKEY_METHOD *, standard_methods, - sizeof(standard_methods)/sizeof(EVP_PKEY_METHOD *), - pmeth_cmp); + ret = OBJ_bsearch_pmeth(&t, standard_methods, + sizeof(standard_methods)/sizeof(EVP_PKEY_METHOD *)); if (!ret || !*ret) return NULL; return *ret; diff --git a/crypto/objects/obj_dat.c b/crypto/objects/obj_dat.c index 3623e152b1..e999ef7831 100644 --- a/crypto/objects/obj_dat.c +++ b/crypto/objects/obj_dat.c @@ -81,9 +81,9 @@ static const unsigned int ln_objs[1]; static const unsigned int obj_objs[1]; #endif -DECLARE_OBJ_BSEARCH_CMP_FN(const ASN1_OBJECT *, unsigned int, sn_cmp); -DECLARE_OBJ_BSEARCH_CMP_FN(const ASN1_OBJECT *, unsigned int, ln_cmp); -DECLARE_OBJ_BSEARCH_CMP_FN(const ASN1_OBJECT *, unsigned int, obj_cmp); +DECLARE_OBJ_BSEARCH_CMP_FN(const ASN1_OBJECT *, unsigned int, sn); +DECLARE_OBJ_BSEARCH_CMP_FN(const ASN1_OBJECT *, unsigned int, ln); +DECLARE_OBJ_BSEARCH_CMP_FN(const ASN1_OBJECT *, unsigned int, obj); #define ADDED_DATA 0 #define ADDED_SNAME 1 @@ -103,12 +103,12 @@ static LHASH_OF(ADDED_OBJ) *added=NULL; static int sn_cmp(const ASN1_OBJECT * const *a, const unsigned int *b) { return(strcmp((*a)->sn,nid_objs[*b].sn)); } -IMPLEMENT_OBJ_BSEARCH_CMP_FN(const ASN1_OBJECT *, unsigned int, sn_cmp); +IMPLEMENT_OBJ_BSEARCH_CMP_FN(const ASN1_OBJECT *, unsigned int, sn); static int ln_cmp(const ASN1_OBJECT * const *a, const unsigned int *b) { return(strcmp((*a)->ln,nid_objs[*b].ln)); } -IMPLEMENT_OBJ_BSEARCH_CMP_FN(const ASN1_OBJECT *, unsigned int, ln_cmp); +IMPLEMENT_OBJ_BSEARCH_CMP_FN(const ASN1_OBJECT *, unsigned int, ln); static unsigned long added_obj_hash(const ADDED_OBJ *ca) { @@ -393,7 +393,7 @@ static int obj_cmp(const ASN1_OBJECT * const *ap, const unsigned int *bp) return(memcmp(a->data,b->data,a->length)); } -IMPLEMENT_OBJ_BSEARCH_CMP_FN(const ASN1_OBJECT *, unsigned int, obj_cmp); +IMPLEMENT_OBJ_BSEARCH_CMP_FN(const ASN1_OBJECT *, unsigned int, obj); int OBJ_obj2nid(const ASN1_OBJECT *a) { @@ -412,8 +412,7 @@ int OBJ_obj2nid(const ASN1_OBJECT *a) adp=lh_ADDED_OBJ_retrieve(added,&ad); if (adp != NULL) return (adp->obj->nid); } - op=OBJ_bsearch(const ASN1_OBJECT *, &a, const unsigned int, obj_objs, - NUM_OBJ, obj_cmp); + op=OBJ_bsearch_obj(&a, obj_objs, NUM_OBJ); if (op == NULL) return(NID_undef); return(nid_objs[*op].nid); @@ -648,8 +647,7 @@ int OBJ_ln2nid(const char *s) adp=lh_ADDED_OBJ_retrieve(added,&ad); if (adp != NULL) return (adp->obj->nid); } - op=OBJ_bsearch(const ASN1_OBJECT *, &oo, const unsigned int, ln_objs, - NUM_LN, ln_cmp); + op=OBJ_bsearch_ln(&oo, ln_objs, NUM_LN); if (op == NULL) return(NID_undef); return(nid_objs[*op].nid); } @@ -669,8 +667,7 @@ int OBJ_sn2nid(const char *s) adp=lh_ADDED_OBJ_retrieve(added,&ad); if (adp != NULL) return (adp->obj->nid); } - op=OBJ_bsearch(const ASN1_OBJECT *, &oo, const unsigned int, sn_objs, - NUM_SN, sn_cmp); + op=OBJ_bsearch_sn(&oo, sn_objs, NUM_SN); if (op == NULL) return(NID_undef); return(nid_objs[*op].nid); } diff --git a/crypto/objects/obj_xref.c b/crypto/objects/obj_xref.c index 30d544b1a4..6230c365a1 100644 --- a/crypto/objects/obj_xref.c +++ b/crypto/objects/obj_xref.c @@ -62,22 +62,22 @@ DECLARE_STACK_OF(nid_triple) STACK_OF(nid_triple) *sig_app, *sigx_app; -static int cmp_sig(const nid_triple *a, const nid_triple *b) +static int sig_cmp(const nid_triple *a, const nid_triple *b) { return a->sign_id - b->sign_id; } -DECLARE_OBJ_BSEARCH_CMP_FN(nid_triple, nid_triple, cmp_sig); -IMPLEMENT_OBJ_BSEARCH_CMP_FN(nid_triple, nid_triple, cmp_sig); +DECLARE_OBJ_BSEARCH_CMP_FN(nid_triple, nid_triple, sig); +IMPLEMENT_OBJ_BSEARCH_CMP_FN(nid_triple, nid_triple, sig); -static int cmp_sig_sk(const nid_triple * const *a, const nid_triple * const *b) +static int sig_sk_cmp(const nid_triple * const *a, const nid_triple * const *b) { return (*a)->sign_id - (*b)->sign_id; } -DECLARE_OBJ_BSEARCH_CMP_FN(const nid_triple *, const nid_triple *, cmp_sigx); +DECLARE_OBJ_BSEARCH_CMP_FN(const nid_triple *, const nid_triple *, sigx); -static int cmp_sigx(const nid_triple * const *a, const nid_triple * const *b) +static int sigx_cmp(const nid_triple * const *a, const nid_triple * const *b) { int ret; ret = (*a)->hash_id - (*b)->hash_id; @@ -86,7 +86,7 @@ static int cmp_sigx(const nid_triple * const *a, const nid_triple * const *b) return (*a)->pkey_id - (*b)->pkey_id; } -IMPLEMENT_OBJ_BSEARCH_CMP_FN(const nid_triple *, const nid_triple *, cmp_sigx); +IMPLEMENT_OBJ_BSEARCH_CMP_FN(const nid_triple *, const nid_triple *, sigx); int OBJ_find_sigid_algs(int signid, int *pdig_nid, int *ppkey_nid) { @@ -104,10 +104,8 @@ int OBJ_find_sigid_algs(int signid, int *pdig_nid, int *ppkey_nid) #ifndef OBJ_XREF_TEST2 if (rv == NULL) { - rv = OBJ_bsearch(const nid_triple,&tmp, - const nid_triple,sigoid_srt, - sizeof(sigoid_srt) / sizeof(nid_triple), - cmp_sig); + rv = OBJ_bsearch_sig(&tmp, sigoid_srt, + sizeof(sigoid_srt) / sizeof(nid_triple)); } #endif if (rv == NULL) @@ -139,10 +137,9 @@ int OBJ_find_sigid_by_algs(int *psignid, int dig_nid, int pkey_nid) #ifndef OBJ_XREF_TEST2 if (rv == NULL) { - rv = OBJ_bsearch(const nid_triple *,&t, - const nid_triple *,sigoid_srt_xref, - sizeof(sigoid_srt_xref) / sizeof(nid_triple *), - cmp_sigx); + rv = OBJ_bsearch_sigx(&t, sigoid_srt_xref, + sizeof(sigoid_srt_xref) / sizeof(nid_triple *) + ); } #endif if (rv == NULL) @@ -155,11 +152,11 @@ int OBJ_add_sigid(int signid, int dig_id, int pkey_id) { nid_triple *ntr; if (!sig_app) - sig_app = sk_nid_triple_new(cmp_sig_sk); + sig_app = sk_nid_triple_new(sig_sk_cmp); if (!sig_app) return 0; if (!sigx_app) - sigx_app = sk_nid_triple_new(cmp_sigx); + sigx_app = sk_nid_triple_new(sigx_cmp); if (!sigx_app) return 0; ntr = OPENSSL_malloc(sizeof(int) * 3); diff --git a/crypto/objects/objects.h b/crypto/objects/objects.h index 3e6d71021b..65b6f01358 100644 --- a/crypto/objects/objects.h +++ b/crypto/objects/objects.h @@ -1018,16 +1018,15 @@ const void * OBJ_bsearch_ex_(const void *key,const void *base,int num, int (*cmp)(const void *, const void *), int flags); -#define _DECLARE_OBJ_BSEARCH_CMP_FN(scope, type1, type2, cmp) \ - scope type1 *cmp##_type_1; \ - scope type2 *cmp##_type_2; \ - scope int cmp##_BSEARCH_CMP_FN(const void *, const void *); \ - scope int cmp(type1 const *, type2 const *) +#define _DECLARE_OBJ_BSEARCH_CMP_FN(scope, type1, type2, nm) \ + static int nm##_cmp_BSEARCH_CMP_FN(const void *, const void *); \ + static int nm##_cmp(type1 const *, type2 const *); \ + scope type2 * OBJ_bsearch_##nm(type1 *key, type2 const *base, int num) #define DECLARE_OBJ_BSEARCH_CMP_FN(type1, type2, cmp) \ _DECLARE_OBJ_BSEARCH_CMP_FN(static, type1, type2, cmp) -#define DECLARE_OBJ_BSEARCH_GLOBAL_CMP_FN(type1, type2, cmp) \ - _DECLARE_OBJ_BSEARCH_CMP_FN(, type1, type2, cmp) +#define DECLARE_OBJ_BSEARCH_GLOBAL_CMP_FN(type1, type2, nm) \ + type2 * OBJ_bsearch_##nm(type1 *key, type2 const *base, int num) /* * Unsolved problem: if a type is actually a pointer type, like @@ -1055,12 +1054,17 @@ const void * OBJ_bsearch_ex_(const void *key,const void *base,int num, * the non-constness means a lot of complication, and in practice * comparison routines do always not touch their arguments. */ -#define _IMPLEMENT_OBJ_BSEARCH_CMP_FN(scope, type1, type2, cmp) \ - scope int cmp##_BSEARCH_CMP_FN(const void *a_, const void *b_) \ +#define _IMPLEMENT_OBJ_BSEARCH_CMP_FN(scope, type1, type2, nm) \ + static int nm##_cmp_BSEARCH_CMP_FN(const void *a_, const void *b_) \ { \ type1 const *a = a_; \ type2 const *b = b_; \ - return cmp(a,b); \ + return nm##_cmp(a,b); \ + } \ + scope type2 *OBJ_bsearch_##nm(type1 *key, type2 const *base, int num) \ + { \ + return (type2 *)OBJ_bsearch_(key, base, num, sizeof(type2), \ + nm##_cmp_BSEARCH_CMP_FN); \ } \ extern void dummy_prototype(void) diff --git a/crypto/x509/x509_vpm.c b/crypto/x509/x509_vpm.c index 5c018e9832..ce8e676c2b 100644 --- a/crypto/x509/x509_vpm.c +++ b/crypto/x509/x509_vpm.c @@ -363,9 +363,9 @@ static int table_cmp(const X509_VERIFY_PARAM *a, const X509_VERIFY_PARAM *b) } DECLARE_OBJ_BSEARCH_CMP_FN(X509_VERIFY_PARAM, X509_VERIFY_PARAM, - table_cmp); + table); IMPLEMENT_OBJ_BSEARCH_CMP_FN(X509_VERIFY_PARAM, X509_VERIFY_PARAM, - table_cmp); + table); static int param_cmp(const X509_VERIFY_PARAM * const *a, const X509_VERIFY_PARAM * const *b) @@ -410,10 +410,8 @@ const X509_VERIFY_PARAM *X509_VERIFY_PARAM_lookup(const char *name) if (idx != -1) return sk_X509_VERIFY_PARAM_value(param_table, idx); } - return OBJ_bsearch(const X509_VERIFY_PARAM, &pm, - const X509_VERIFY_PARAM, default_table, - sizeof(default_table)/sizeof(X509_VERIFY_PARAM), - table_cmp); + return OBJ_bsearch_table(&pm, default_table, + sizeof(default_table)/sizeof(X509_VERIFY_PARAM)); } void X509_VERIFY_PARAM_table_cleanup(void) diff --git a/crypto/x509v3/v3_lib.c b/crypto/x509v3/v3_lib.c index 3ad5b29afc..dad0c905c2 100644 --- a/crypto/x509v3/v3_lib.c +++ b/crypto/x509v3/v3_lib.c @@ -90,9 +90,9 @@ static int ext_cmp(const X509V3_EXT_METHOD * const *a, } DECLARE_OBJ_BSEARCH_CMP_FN(const X509V3_EXT_METHOD *, const X509V3_EXT_METHOD *, - ext_cmp); + ext); IMPLEMENT_OBJ_BSEARCH_CMP_FN(const X509V3_EXT_METHOD *, - const X509V3_EXT_METHOD *, ext_cmp); + const X509V3_EXT_METHOD *, ext); const X509V3_EXT_METHOD *X509V3_EXT_get_nid(int nid) { @@ -101,9 +101,7 @@ const X509V3_EXT_METHOD *X509V3_EXT_get_nid(int nid) int idx; if(nid < 0) return NULL; tmp.ext_nid = nid; - ret = OBJ_bsearch(const X509V3_EXT_METHOD *, &t, - const X509V3_EXT_METHOD *, standard_exts, - STANDARD_EXTENSION_COUNT, ext_cmp); + ret = OBJ_bsearch_ext(&t, standard_exts, STANDARD_EXTENSION_COUNT); if(ret) return *ret; if(!ext_list) return NULL; idx = sk_X509V3_EXT_METHOD_find(ext_list, &tmp); diff --git a/crypto/x509v3/v3_purp.c b/crypto/x509v3/v3_purp.c index a5d9805ce4..e00c9ec130 100644 --- a/crypto/x509v3/v3_purp.c +++ b/crypto/x509v3/v3_purp.c @@ -272,8 +272,8 @@ static int nid_cmp(const int *a, const int *b) return *a - *b; } -DECLARE_OBJ_BSEARCH_CMP_FN(int, int, nid_cmp); -IMPLEMENT_OBJ_BSEARCH_CMP_FN(int, int, nid_cmp); +DECLARE_OBJ_BSEARCH_CMP_FN(int, int, nid); +IMPLEMENT_OBJ_BSEARCH_CMP_FN(int, int, nid); int X509_supported_extension(X509_EXTENSION *ex) { @@ -303,13 +303,13 @@ int X509_supported_extension(X509_EXTENSION *ex) NID_inhibit_any_policy /* 748 */ }; - const int ex_nid = OBJ_obj2nid(X509_EXTENSION_get_object(ex)); + int ex_nid = OBJ_obj2nid(X509_EXTENSION_get_object(ex)); if (ex_nid == NID_undef) return 0; - if (OBJ_bsearch(int, &ex_nid, int, supported_nids, - sizeof(supported_nids)/sizeof(int), nid_cmp)) + if (OBJ_bsearch_nid(&ex_nid, supported_nids, + sizeof(supported_nids)/sizeof(int))) return 1; return 0; } diff --git a/ssl/s2_lib.c b/ssl/s2_lib.c index 0f311c3fab..4cfafcedf1 100644 --- a/ssl/s2_lib.c +++ b/ssl/s2_lib.c @@ -413,7 +413,7 @@ long ssl2_ctx_callback_ctrl(SSL_CTX *ctx, int cmd, void (*fp)(void)) } IMPLEMENT_OBJ_BSEARCH_GLOBAL_CMP_FN(SSL_CIPHER, SSL_CIPHER, - ssl_cipher_id_cmp); + ssl_cipher_id); /* This function needs to check if the ciphers required are actually * available */ @@ -426,8 +426,7 @@ const SSL_CIPHER *ssl2_get_cipher_by_char(const unsigned char *p) id=0x02000000L|((unsigned long)p[0]<<16L)| ((unsigned long)p[1]<<8L)|(unsigned long)p[2]; c.id=id; - cp = OBJ_bsearch(const SSL_CIPHER, &c, const SSL_CIPHER, ssl2_ciphers, - SSL2_NUM_CIPHERS, ssl_cipher_id_cmp); + cp = OBJ_bsearch_ssl_cipher_id(&c, ssl2_ciphers, SSL2_NUM_CIPHERS); if ((cp == NULL) || (cp->valid == 0)) return NULL; else diff --git a/ssl/s3_lib.c b/ssl/s3_lib.c index 7e896997b2..54c0540493 100644 --- a/ssl/s3_lib.c +++ b/ssl/s3_lib.c @@ -2794,8 +2794,7 @@ const SSL_CIPHER *ssl3_get_cipher_by_char(const unsigned char *p) id=0x03000000L|((unsigned long)p[0]<<8L)|(unsigned long)p[1]; c.id=id; - cp = OBJ_bsearch(SSL_CIPHER, &c, SSL_CIPHER, ssl3_ciphers, - SSL3_NUM_CIPHERS, ssl_cipher_id_cmp); + cp = OBJ_bsearch_ssl_cipher_id(&c, ssl3_ciphers, SSL3_NUM_CIPHERS); if (cp == NULL || cp->valid == 0) return NULL; else diff --git a/ssl/ssl_locl.h b/ssl/ssl_locl.h index e478f9aa72..30bd74676c 100644 --- a/ssl/ssl_locl.h +++ b/ssl/ssl_locl.h @@ -785,7 +785,7 @@ int ssl_get_new_session(SSL *s, int session); int ssl_get_prev_session(SSL *s, unsigned char *session,int len, const unsigned char *limit); int ssl_cipher_id_cmp(const SSL_CIPHER *a,const SSL_CIPHER *b); DECLARE_OBJ_BSEARCH_GLOBAL_CMP_FN(SSL_CIPHER, SSL_CIPHER, - ssl_cipher_id_cmp); + ssl_cipher_id); int ssl_cipher_ptr_id_cmp(const SSL_CIPHER * const *ap, const SSL_CIPHER * const *bp); STACK_OF(SSL_CIPHER) *ssl_bytes_to_cipher_list(SSL *s,unsigned char *p,int num, |