diff options
Diffstat (limited to 'src/lib/libcrypto/asn1/asn_moid.c')
| -rw-r--r-- | src/lib/libcrypto/asn1/asn_moid.c | 33 |
1 files changed, 19 insertions, 14 deletions
diff --git a/src/lib/libcrypto/asn1/asn_moid.c b/src/lib/libcrypto/asn1/asn_moid.c index 0c09a8e934..7ddf212e9a 100644 --- a/src/lib/libcrypto/asn1/asn_moid.c +++ b/src/lib/libcrypto/asn1/asn_moid.c | |||
| @@ -10,7 +10,7 @@ | |||
| 10 | * are met: | 10 | * are met: |
| 11 | * | 11 | * |
| 12 | * 1. Redistributions of source code must retain the above copyright | 12 | * 1. Redistributions of source code must retain the above copyright |
| 13 | * notice, this list of conditions and the following disclaimer. | 13 | * notice, this list of conditions and the following disclaimer. |
| 14 | * | 14 | * |
| 15 | * 2. Redistributions in binary form must reproduce the above copyright | 15 | * 2. Redistributions in binary form must reproduce the above copyright |
| 16 | * notice, this list of conditions and the following disclaimer in | 16 | * notice, this list of conditions and the following disclaimer in |
| @@ -68,20 +68,22 @@ | |||
| 68 | 68 | ||
| 69 | static int do_create(char *value, char *name); | 69 | static int do_create(char *value, char *name); |
| 70 | 70 | ||
| 71 | static int oid_module_init(CONF_IMODULE *md, const CONF *cnf) | 71 | static int |
| 72 | oid_module_init(CONF_IMODULE *md, const CONF *cnf) | ||
| 72 | { | 73 | { |
| 73 | int i; | 74 | int i; |
| 74 | const char *oid_section; | 75 | const char *oid_section; |
| 75 | STACK_OF(CONF_VALUE) *sktmp; | 76 | STACK_OF(CONF_VALUE) *sktmp; |
| 76 | CONF_VALUE *oval; | 77 | CONF_VALUE *oval; |
| 78 | |||
| 77 | oid_section = CONF_imodule_get_value(md); | 79 | oid_section = CONF_imodule_get_value(md); |
| 78 | if(!(sktmp = NCONF_get_section(cnf, oid_section))) { | 80 | if (!(sktmp = NCONF_get_section(cnf, oid_section))) { |
| 79 | ASN1err(ASN1_F_OID_MODULE_INIT, ASN1_R_ERROR_LOADING_SECTION); | 81 | ASN1err(ASN1_F_OID_MODULE_INIT, ASN1_R_ERROR_LOADING_SECTION); |
| 80 | return 0; | 82 | return 0; |
| 81 | } | 83 | } |
| 82 | for(i = 0; i < sk_CONF_VALUE_num(sktmp); i++) { | 84 | for (i = 0; i < sk_CONF_VALUE_num(sktmp); i++) { |
| 83 | oval = sk_CONF_VALUE_value(sktmp, i); | 85 | oval = sk_CONF_VALUE_value(sktmp, i); |
| 84 | if(!do_create(oval->value, oval->name)) { | 86 | if (!do_create(oval->value, oval->name)) { |
| 85 | ASN1err(ASN1_F_OID_MODULE_INIT, ASN1_R_ADDING_OBJECT); | 87 | ASN1err(ASN1_F_OID_MODULE_INIT, ASN1_R_ADDING_OBJECT); |
| 86 | return 0; | 88 | return 0; |
| 87 | } | 89 | } |
| @@ -89,12 +91,14 @@ static int oid_module_init(CONF_IMODULE *md, const CONF *cnf) | |||
| 89 | return 1; | 91 | return 1; |
| 90 | } | 92 | } |
| 91 | 93 | ||
| 92 | static void oid_module_finish(CONF_IMODULE *md) | 94 | static void |
| 95 | oid_module_finish(CONF_IMODULE *md) | ||
| 93 | { | 96 | { |
| 94 | OBJ_cleanup(); | 97 | OBJ_cleanup(); |
| 95 | } | 98 | } |
| 96 | 99 | ||
| 97 | void ASN1_add_oid_module(void) | 100 | void |
| 101 | ASN1_add_oid_module(void) | ||
| 98 | { | 102 | { |
| 99 | CONF_module_add("oid_section", oid_module_init, oid_module_finish); | 103 | CONF_module_add("oid_section", oid_module_init, oid_module_finish); |
| 100 | } | 104 | } |
| @@ -104,12 +108,13 @@ void ASN1_add_oid_module(void) | |||
| 104 | * shortname = some long name, 1.2.3.4 | 108 | * shortname = some long name, 1.2.3.4 |
| 105 | */ | 109 | */ |
| 106 | 110 | ||
| 107 | 111 | static int | |
| 108 | static int do_create(char *value, char *name) | 112 | do_create(char *value, char *name) |
| 109 | { | 113 | { |
| 110 | int nid; | 114 | int nid; |
| 111 | ASN1_OBJECT *oid; | 115 | ASN1_OBJECT *oid; |
| 112 | char *ln, *ostr, *p, *lntmp; | 116 | char *ln, *ostr, *p, *lntmp; |
| 117 | |||
| 113 | p = strrchr(value, ','); | 118 | p = strrchr(value, ','); |
| 114 | if (!p) { | 119 | if (!p) { |
| 115 | ln = name; | 120 | ln = name; |
| @@ -119,7 +124,8 @@ static int do_create(char *value, char *name) | |||
| 119 | ostr = p + 1; | 124 | ostr = p + 1; |
| 120 | if (!*ostr) | 125 | if (!*ostr) |
| 121 | return 0; | 126 | return 0; |
| 122 | while(isspace((unsigned char)*ostr)) ostr++; | 127 | while (isspace((unsigned char)*ostr)) |
| 128 | ostr++; | ||
| 123 | } | 129 | } |
| 124 | 130 | ||
| 125 | nid = OBJ_create(ostr, name, ln); | 131 | nid = OBJ_create(ostr, name, ln); |
| @@ -129,9 +135,10 @@ static int do_create(char *value, char *name) | |||
| 129 | 135 | ||
| 130 | if (p) { | 136 | if (p) { |
| 131 | ln = value; | 137 | ln = value; |
| 132 | while(isspace((unsigned char)*ln)) ln++; | 138 | while (isspace((unsigned char)*ln)) |
| 139 | ln++; | ||
| 133 | p--; | 140 | p--; |
| 134 | while(isspace((unsigned char)*p)) { | 141 | while (isspace((unsigned char)*p)) { |
| 135 | if (p == ln) | 142 | if (p == ln) |
| 136 | return 0; | 143 | return 0; |
| 137 | p--; | 144 | p--; |
| @@ -148,5 +155,3 @@ static int do_create(char *value, char *name) | |||
| 148 | 155 | ||
| 149 | return 1; | 156 | return 1; |
| 150 | } | 157 | } |
| 151 | |||
| 152 | |||
