diff options
author | Richard Levitte <levitte@openssl.org> | 2000-10-27 20:18:00 +0000 |
---|---|---|
committer | Richard Levitte <levitte@openssl.org> | 2000-10-27 20:18:00 +0000 |
commit | 1433ae4790d650009c9654fd93e704ff3e85addb (patch) | |
tree | 02f13f80fdda74912aecde0f0207f0f54298899a /crypto/conf/conf_lib.c | |
parent | a5061532191691b3fb7704be751c1fbecdd65288 (diff) |
Fix from main trunk, 2000-10-13 10:30 levitte:
Make the new conf implementatoin bug-compatible with the old one.
Actually, it's a feature that it goes looking at environment
variables. It's just a pity that it's at the cost of the error
checking... I'll see if I can come up with a better interface for
this.
Fix from main trunk, 2000-10-16 15:08 ben:
Always return a value.
Diffstat (limited to 'crypto/conf/conf_lib.c')
-rw-r--r-- | crypto/conf/conf_lib.c | 27 |
1 files changed, 23 insertions, 4 deletions
diff --git a/crypto/conf/conf_lib.c b/crypto/conf/conf_lib.c index 4c8ca9e9ae..51bd0db655 100644 --- a/crypto/conf/conf_lib.c +++ b/crypto/conf/conf_lib.c @@ -299,27 +299,46 @@ STACK_OF(CONF_VALUE) *NCONF_get_section(CONF *conf,char *section) return NULL; } + if (section == NULL) + { + CONFerr(CONF_F_NCONF_GET_SECTION,CONF_R_NO_SECTION); + return NULL; + } + return _CONF_get_section_values(conf, section); } char *NCONF_get_string(CONF *conf,char *group,char *name) { + char *s = _CONF_get_string(conf, group, name); + + /* Since we may get a value from an environment variable even + if conf is NULL, let's check the value first */ + if (s) return s; + if (conf == NULL) { - CONFerr(CONF_F_NCONF_GET_STRING,CONF_R_NO_CONF); + CONFerr(CONF_F_NCONF_GET_STRING, + CONF_R_NO_CONF_OR_ENVIRONMENT_VARIABLE); return NULL; } - - return _CONF_get_string(conf, group, name); + return NULL; } long NCONF_get_number(CONF *conf,char *group,char *name) { +#if 0 /* As with _CONF_get_string(), we rely on the possibility of finding + an environment variable with a suitable name. Unfortunately, there's + no way with the current API to see if we found one or not... + The meaning of this is that if a number is not found anywhere, it + will always default to 0. */ if (conf == NULL) { - CONFerr(CONF_F_NCONF_GET_NUMBER,CONF_R_NO_CONF); + CONFerr(CONF_F_NCONF_GET_NUMBER, + CONF_R_NO_CONF_OR_ENVIRONMENT_VARIABLE); return 0; } +#endif return _CONF_get_number(conf, group, name); } |