diff options
author | Matt Caswell <matt@openssl.org> | 2019-07-30 17:42:53 +0200 |
---|---|---|
committer | Matt Caswell <matt@openssl.org> | 2019-08-01 10:59:20 +0200 |
commit | 29dc6e00f2a1ec93bbacc5127cecf3412e95e57f (patch) | |
tree | e14982624eb7d057b64d73fdc7a617f49a0ff178 /crypto/objects | |
parent | Suppress loading the FIPS module in evp_test (diff) | |
download | openssl-29dc6e00f2a1ec93bbacc5127cecf3412e95e57f.tar.xz openssl-29dc6e00f2a1ec93bbacc5127cecf3412e95e57f.zip |
Load the config file by default
Previously we only loaded the config file by default for libssl. Now we do
it for libcrypto too.
Reviewed-by: Richard Levitte <levitte@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/9492)
Diffstat (limited to 'crypto/objects')
-rw-r--r-- | crypto/objects/obj_dat.c | 96 |
1 files changed, 57 insertions, 39 deletions
diff --git a/crypto/objects/obj_dat.c b/crypto/objects/obj_dat.c index ec9e131337..c4155a3dfc 100644 --- a/crypto/objects/obj_dat.c +++ b/crypto/objects/obj_dat.c @@ -228,20 +228,23 @@ ASN1_OBJECT *OBJ_nid2obj(int n) return NULL; } return (ASN1_OBJECT *)&(nid_objs[n]); - } else if (added == NULL) - return NULL; - else { - ad.type = ADDED_NID; - ad.obj = &ob; - ob.nid = n; - adp = lh_ADDED_OBJ_retrieve(added, &ad); - if (adp != NULL) - return adp->obj; - else { - OBJerr(OBJ_F_OBJ_NID2OBJ, OBJ_R_UNKNOWN_NID); - return NULL; - } } + + /* Make sure we've loaded config before checking for any "added" objects */ + OPENSSL_init_crypto(OPENSSL_INIT_LOAD_CONFIG, NULL); + + if (added == NULL) + return NULL; + + ad.type = ADDED_NID; + ad.obj = &ob; + ob.nid = n; + adp = lh_ADDED_OBJ_retrieve(added, &ad); + if (adp != NULL) + return adp->obj; + + OBJerr(OBJ_F_OBJ_NID2OBJ, OBJ_R_UNKNOWN_NID); + return NULL; } const char *OBJ_nid2sn(int n) @@ -255,20 +258,23 @@ const char *OBJ_nid2sn(int n) return NULL; } return nid_objs[n].sn; - } else if (added == NULL) - return NULL; - else { - ad.type = ADDED_NID; - ad.obj = &ob; - ob.nid = n; - adp = lh_ADDED_OBJ_retrieve(added, &ad); - if (adp != NULL) - return adp->obj->sn; - else { - OBJerr(OBJ_F_OBJ_NID2SN, OBJ_R_UNKNOWN_NID); - return NULL; - } } + + /* Make sure we've loaded config before checking for any "added" objects */ + OPENSSL_init_crypto(OPENSSL_INIT_LOAD_CONFIG, NULL); + + if (added == NULL) + return NULL; + + ad.type = ADDED_NID; + ad.obj = &ob; + ob.nid = n; + adp = lh_ADDED_OBJ_retrieve(added, &ad); + if (adp != NULL) + return adp->obj->sn; + + OBJerr(OBJ_F_OBJ_NID2SN, OBJ_R_UNKNOWN_NID); + return NULL; } const char *OBJ_nid2ln(int n) @@ -282,20 +288,23 @@ const char *OBJ_nid2ln(int n) return NULL; } return nid_objs[n].ln; - } else if (added == NULL) - return NULL; - else { - ad.type = ADDED_NID; - ad.obj = &ob; - ob.nid = n; - adp = lh_ADDED_OBJ_retrieve(added, &ad); - if (adp != NULL) - return adp->obj->ln; - else { - OBJerr(OBJ_F_OBJ_NID2LN, OBJ_R_UNKNOWN_NID); - return NULL; - } } + + /* Make sure we've loaded config before checking for any "added" objects */ + OPENSSL_init_crypto(OPENSSL_INIT_LOAD_CONFIG, NULL); + + if (added == NULL) + return NULL; + + ad.type = ADDED_NID; + ad.obj = &ob; + ob.nid = n; + adp = lh_ADDED_OBJ_retrieve(added, &ad); + if (adp != NULL) + return adp->obj->ln; + + OBJerr(OBJ_F_OBJ_NID2LN, OBJ_R_UNKNOWN_NID); + return NULL; } static int obj_cmp(const ASN1_OBJECT *const *ap, const unsigned int *bp) @@ -327,6 +336,9 @@ int OBJ_obj2nid(const ASN1_OBJECT *a) if (a->length == 0) return NID_undef; + /* Make sure we've loaded config before checking for any "added" objects */ + OPENSSL_init_crypto(OPENSSL_INIT_LOAD_CONFIG, NULL); + if (added != NULL) { ad.type = ADDED_DATA; ad.obj = (ASN1_OBJECT *)a; /* XXX: ugly but harmless */ @@ -544,6 +556,9 @@ int OBJ_ln2nid(const char *s) ADDED_OBJ ad, *adp; const unsigned int *op; + /* Make sure we've loaded config before checking for any "added" objects */ + OPENSSL_init_crypto(OPENSSL_INIT_LOAD_CONFIG, NULL); + o.ln = s; if (added != NULL) { ad.type = ADDED_LNAME; @@ -565,6 +580,9 @@ int OBJ_sn2nid(const char *s) ADDED_OBJ ad, *adp; const unsigned int *op; + /* Make sure we've loaded config before checking for any "added" objects */ + OPENSSL_init_crypto(OPENSSL_INIT_LOAD_CONFIG, NULL); + o.sn = s; if (added != NULL) { ad.type = ADDED_SNAME; |