Don't call finish function if it isn't set.
authorDr. Stephen Henson <steve@openssl.org>
Fri, 15 Feb 2002 00:33:35 +0000 (00:33 +0000)
committerDr. Stephen Henson <steve@openssl.org>
Fri, 15 Feb 2002 00:33:35 +0000 (00:33 +0000)
Fix OID module.

crypto/asn1/asn1.h
crypto/asn1/asn1_err.c
crypto/asn1/asn_moid.c
crypto/conf/conf_mod.c

index d8474dc6851d499ce93fb2c811db1f10fe61cb45..80cf9f5bea0e1b9f9be86e3f29960225362dd4df 100644 (file)
@@ -1011,6 +1011,7 @@ void ERR_load_ASN1_strings(void);
 #define ASN1_F_I2D_PUBLICKEY                            164
 #define ASN1_F_I2D_RSA_PUBKEY                           165
 #define ASN1_F_LONG_C2I                                         166
+#define ASN1_F_OID_MODULE_INIT                          174
 #define ASN1_F_PKCS5_PBE2_SET                           167
 #define ASN1_F_X509_CINF_NEW                            168
 #define ASN1_F_X509_CRL_ADD0_REVOKED                    169
@@ -1020,6 +1021,7 @@ void ERR_load_ASN1_strings(void);
 #define ASN1_F_X509_PKEY_NEW                            173
 
 /* Reason codes. */
+#define ASN1_R_ADDING_OBJECT                            171
 #define ASN1_R_AUX_ERROR                                100
 #define ASN1_R_BAD_CLASS                                101
 #define ASN1_R_BAD_OBJECT_HEADER                        102
@@ -1033,6 +1035,7 @@ void ERR_load_ASN1_strings(void);
 #define ASN1_R_DECODE_ERROR                             110
 #define ASN1_R_DECODING_ERROR                           111
 #define ASN1_R_ENCODE_ERROR                             112
+#define ASN1_R_ERROR_LOADING_SECTION                    172
 #define ASN1_R_ERROR_PARSING_SET_ELEMENT                113
 #define ASN1_R_ERROR_SETTING_CIPHER_PARAMS              114
 #define ASN1_R_EXPECTING_AN_INTEGER                     115
index 591f55dde5ca337fdbde108ef71d0e67a4a33612..c4c3d2a91df192006939a5a3b0450cb3c9acd5b5 100644 (file)
@@ -133,6 +133,7 @@ static ERR_STRING_DATA ASN1_str_functs[]=
 {ERR_PACK(0,ASN1_F_I2D_PUBLICKEY,0),   "i2d_PublicKey"},
 {ERR_PACK(0,ASN1_F_I2D_RSA_PUBKEY,0),  "i2d_RSA_PUBKEY"},
 {ERR_PACK(0,ASN1_F_LONG_C2I,0),        "LONG_C2I"},
+{ERR_PACK(0,ASN1_F_OID_MODULE_INIT,0), "OID_MODULE_INIT"},
 {ERR_PACK(0,ASN1_F_PKCS5_PBE2_SET,0),  "PKCS5_pbe2_set"},
 {ERR_PACK(0,ASN1_F_X509_CINF_NEW,0),   "X509_CINF_NEW"},
 {ERR_PACK(0,ASN1_F_X509_CRL_ADD0_REVOKED,0),   "X509_CRL_add0_revoked"},
@@ -145,6 +146,7 @@ static ERR_STRING_DATA ASN1_str_functs[]=
 
 static ERR_STRING_DATA ASN1_str_reasons[]=
        {
+{ASN1_R_ADDING_OBJECT                    ,"adding object"},
 {ASN1_R_AUX_ERROR                        ,"aux error"},
 {ASN1_R_BAD_CLASS                        ,"bad class"},
 {ASN1_R_BAD_OBJECT_HEADER                ,"bad object header"},
@@ -158,6 +160,7 @@ static ERR_STRING_DATA ASN1_str_reasons[]=
 {ASN1_R_DECODE_ERROR                     ,"decode error"},
 {ASN1_R_DECODING_ERROR                   ,"decoding error"},
 {ASN1_R_ENCODE_ERROR                     ,"encode error"},
+{ASN1_R_ERROR_LOADING_SECTION            ,"error loading section"},
 {ASN1_R_ERROR_PARSING_SET_ELEMENT        ,"error parsing set element"},
 {ASN1_R_ERROR_SETTING_CIPHER_PARAMS      ,"error setting cipher params"},
 {ASN1_R_EXPECTING_AN_INTEGER             ,"expecting an integer"},
index b0337879887c34f6985e5220f0a8e4f75cc01c4a..2f982725fdf73910be01d46e9860f40bc3f68c19 100644 (file)
 /* NOTE: doesn't do anything other than print debug messages yet... */
 static int oid_module_init(CONF_IMODULE *md, const CONF *cnf)
        {
-       fprintf(stderr, "Called oid_module_init: name %s, value %s\n",
-                       CONF_imodule_get_name(md), CONF_imodule_get_value(md));
+       int i;
+       const char *oid_section;
+       STACK_OF(CONF_VALUE) *sktmp;
+       CONF_VALUE *oval;
+       oid_section = CONF_imodule_get_value(md);
+       if(!(sktmp = NCONF_get_section(cnf, oid_section)))
+               {
+               ASN1err(ASN1_F_OID_MODULE_INIT, ASN1_R_ERROR_LOADING_SECTION);
+               return 0;
+               }
+       for(i = 0; i < sk_CONF_VALUE_num(sktmp); i++)
+               {
+               oval = sk_CONF_VALUE_value(sktmp, i);
+               if(OBJ_create(oval->value, oval->name, oval->name) == NID_undef)
+                       {
+                       ASN1err(ASN1_F_OID_MODULE_INIT, ASN1_R_ADDING_OBJECT);
+                       return 0;
+                       }
+               }
        return 1;
-       }
-
-static void oid_module_finish(CONF_IMODULE *md)
-       {
-       fprintf(stderr, "Called oid_module_finish: name %s, value %s\n",
-                       CONF_imodule_get_name(md), CONF_imodule_get_value(md));
-       }
+}
 
 void ASN1_add_oid_module(void)
        {
-       CONF_module_add("oid_section", oid_module_init, oid_module_finish);
+       CONF_module_add("oid_section", oid_module_init, 0);
        }
index 426d69337f7307339c1913bb82c59e9ed591ed9d..c548d0f27bb794fb53e80a07143721842ed378ba 100644 (file)
@@ -256,11 +256,6 @@ static CONF_MODULE *module_load_dso(const CONF *cnf, char *name, char *value,
                goto err;
                }
         ffunc = (conf_finish_func *)DSO_bind_func(dso, DSO_mod_finish_name);
-       if (!ffunc)
-               {
-               errcode = CONF_R_MISSING_FINISH_FUNCTION;
-               goto err;
-               }
        /* All OK, add module */
        md = module_add(dso, name, ifunc, ffunc);
 
@@ -458,7 +453,8 @@ void CONF_modules_finish(void)
 
 static void module_finish(CONF_IMODULE *imod)
        {
-       imod->pmod->finish(imod);
+       if (imod->pmod->finish)
+               imod->pmod->finish(imod);
        imod->pmod->links--;
        OPENSSL_free(imod->name);
        OPENSSL_free(imod->value);