summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/conf/conf_lib.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libcrypto/conf/conf_lib.c')
-rw-r--r--src/lib/libcrypto/conf/conf_lib.c84
1 files changed, 62 insertions, 22 deletions
diff --git a/src/lib/libcrypto/conf/conf_lib.c b/src/lib/libcrypto/conf/conf_lib.c
index 4c8ca9e9ae..11ec639732 100644
--- a/src/lib/libcrypto/conf/conf_lib.c
+++ b/src/lib/libcrypto/conf/conf_lib.c
@@ -131,38 +131,59 @@ LHASH *CONF_load_bio(LHASH *conf, BIO *bp,long *eline)
131 131
132STACK_OF(CONF_VALUE) *CONF_get_section(LHASH *conf,char *section) 132STACK_OF(CONF_VALUE) *CONF_get_section(LHASH *conf,char *section)
133 { 133 {
134 CONF ctmp; 134 if (conf == NULL)
135 {
136 return NULL;
137 }
138 else
139 {
140 CONF ctmp;
135 141
136 if (default_CONF_method == NULL) 142 if (default_CONF_method == NULL)
137 default_CONF_method = NCONF_default(); 143 default_CONF_method = NCONF_default();
138 144
139 default_CONF_method->init(&ctmp); 145 default_CONF_method->init(&ctmp);
140 ctmp.data = conf; 146 ctmp.data = conf;
141 return NCONF_get_section(&ctmp, section); 147 return NCONF_get_section(&ctmp, section);
148 }
142 } 149 }
143 150
144char *CONF_get_string(LHASH *conf,char *group,char *name) 151char *CONF_get_string(LHASH *conf,char *group,char *name)
145 { 152 {
146 CONF ctmp; 153 if (conf == NULL)
154 {
155 return NCONF_get_string(NULL, group, name);
156 }
157 else
158 {
159 CONF ctmp;
147 160
148 if (default_CONF_method == NULL) 161 if (default_CONF_method == NULL)
149 default_CONF_method = NCONF_default(); 162 default_CONF_method = NCONF_default();
150 163
151 default_CONF_method->init(&ctmp); 164 default_CONF_method->init(&ctmp);
152 ctmp.data = conf; 165 ctmp.data = conf;
153 return NCONF_get_string(&ctmp, group, name); 166 return NCONF_get_string(&ctmp, group, name);
167 }
154 } 168 }
155 169
156long CONF_get_number(LHASH *conf,char *group,char *name) 170long CONF_get_number(LHASH *conf,char *group,char *name)
157 { 171 {
158 CONF ctmp; 172 if (conf == NULL)
173 {
174 return NCONF_get_number(NULL, group, name);
175 }
176 else
177 {
178 CONF ctmp;
159 179
160 if (default_CONF_method == NULL) 180 if (default_CONF_method == NULL)
161 default_CONF_method = NCONF_default(); 181 default_CONF_method = NCONF_default();
162 182
163 default_CONF_method->init(&ctmp); 183 default_CONF_method->init(&ctmp);
164 ctmp.data = conf; 184 ctmp.data = conf;
165 return NCONF_get_number(&ctmp, group, name); 185 return NCONF_get_number(&ctmp, group, name);
186 }
166 } 187 }
167 188
168void CONF_free(LHASH *conf) 189void CONF_free(LHASH *conf)
@@ -299,27 +320,46 @@ STACK_OF(CONF_VALUE) *NCONF_get_section(CONF *conf,char *section)
299 return NULL; 320 return NULL;
300 } 321 }
301 322
323 if (section == NULL)
324 {
325 CONFerr(CONF_F_NCONF_GET_SECTION,CONF_R_NO_SECTION);
326 return NULL;
327 }
328
302 return _CONF_get_section_values(conf, section); 329 return _CONF_get_section_values(conf, section);
303 } 330 }
304 331
305char *NCONF_get_string(CONF *conf,char *group,char *name) 332char *NCONF_get_string(CONF *conf,char *group,char *name)
306 { 333 {
334 char *s = _CONF_get_string(conf, group, name);
335
336 /* Since we may get a value from an environment variable even
337 if conf is NULL, let's check the value first */
338 if (s) return s;
339
307 if (conf == NULL) 340 if (conf == NULL)
308 { 341 {
309 CONFerr(CONF_F_NCONF_GET_STRING,CONF_R_NO_CONF); 342 CONFerr(CONF_F_NCONF_GET_STRING,
343 CONF_R_NO_CONF_OR_ENVIRONMENT_VARIABLE);
310 return NULL; 344 return NULL;
311 } 345 }
312 346 return NULL;
313 return _CONF_get_string(conf, group, name);
314 } 347 }
315 348
316long NCONF_get_number(CONF *conf,char *group,char *name) 349long NCONF_get_number(CONF *conf,char *group,char *name)
317 { 350 {
351#if 0 /* As with _CONF_get_string(), we rely on the possibility of finding
352 an environment variable with a suitable name. Unfortunately, there's
353 no way with the current API to see if we found one or not...
354 The meaning of this is that if a number is not found anywhere, it
355 will always default to 0. */
318 if (conf == NULL) 356 if (conf == NULL)
319 { 357 {
320 CONFerr(CONF_F_NCONF_GET_NUMBER,CONF_R_NO_CONF); 358 CONFerr(CONF_F_NCONF_GET_NUMBER,
359 CONF_R_NO_CONF_OR_ENVIRONMENT_VARIABLE);
321 return 0; 360 return 0;
322 } 361 }
362#endif
323 363
324 return _CONF_get_number(conf, group, name); 364 return _CONF_get_number(conf, group, name);
325 } 365 }