2016-05-18 02:24:46 +08:00
|
|
|
/*
|
2024-09-05 15:35:49 +08:00
|
|
|
* Copyright 1995-2024 The OpenSSL Project Authors. All Rights Reserved.
|
1998-12-21 18:52:47 +08:00
|
|
|
*
|
2018-12-06 20:34:05 +08:00
|
|
|
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
2016-05-18 02:24:46 +08:00
|
|
|
* this file except in compliance with the License. You can obtain a copy
|
|
|
|
* in the file LICENSE in the source distribution or at
|
|
|
|
* https://www.openssl.org/source/license.html
|
1998-12-21 18:52:47 +08:00
|
|
|
*/
|
|
|
|
|
I've always wanted to make the CONF library more adaptable. Here's
the result.
I have retained the old behavior of the CONF_* functions, and have
added a more "object oriented" interface through NCONF_* functions
(New CONF, you see :-)), working the same way as, for example, the
BIO interface. Really, the CONF_* are rewritten so they use the
NCONF_* functions internally.
In addition to that, I've split the old conf.c code into two files,
conf_def.c and conf_api.c. conf_def.c contains the default config
object that reads a configuration file the standard OpenSSL way, as
well as configuration file with Win32 registry file syntax (I'm not
sure I got that one right). conf_api.c provides an API to build other
configuration file readers around (can you see a configuraion file in
XML? I can :-)).
Finally, I've changed the name conf_lcl.h to conf_def.h, since it's
made specifically for that "class" and none others.
2000-04-09 20:04:35 +08:00
|
|
|
/* Part of the code in here was originally in conf.c, which is now removed */
|
|
|
|
|
1998-12-21 18:52:47 +08:00
|
|
|
#include <stdio.h>
|
2000-06-06 23:21:12 +08:00
|
|
|
#include <string.h>
|
2022-04-12 18:30:08 +08:00
|
|
|
#include "internal/e_os.h" /* struct stat */
|
2020-09-07 05:37:47 +08:00
|
|
|
#ifdef __TANDEM
|
2021-03-26 20:34:49 +08:00
|
|
|
# include <sys/types.h> /* needed for stat.h */
|
|
|
|
# include <sys/stat.h> /* struct stat */
|
2020-09-07 05:37:47 +08:00
|
|
|
#endif
|
2015-05-14 22:56:48 +08:00
|
|
|
#include "internal/cryptlib.h"
|
2018-02-27 20:55:35 +08:00
|
|
|
#include "internal/o_dir.h"
|
1999-04-24 06:13:45 +08:00
|
|
|
#include <openssl/lhash.h>
|
|
|
|
#include <openssl/conf.h>
|
I've always wanted to make the CONF library more adaptable. Here's
the result.
I have retained the old behavior of the CONF_* functions, and have
added a more "object oriented" interface through NCONF_* functions
(New CONF, you see :-)), working the same way as, for example, the
BIO interface. Really, the CONF_* are rewritten so they use the
NCONF_* functions internally.
In addition to that, I've split the old conf.c code into two files,
conf_def.c and conf_api.c. conf_def.c contains the default config
object that reads a configuration file the standard OpenSSL way, as
well as configuration file with Win32 registry file syntax (I'm not
sure I got that one right). conf_api.c provides an API to build other
configuration file readers around (can you see a configuraion file in
XML? I can :-)).
Finally, I've changed the name conf_lcl.h to conf_def.h, since it's
made specifically for that "class" and none others.
2000-04-09 20:04:35 +08:00
|
|
|
#include <openssl/conf_api.h>
|
2021-05-26 00:57:06 +08:00
|
|
|
#include "conf_local.h"
|
I've always wanted to make the CONF library more adaptable. Here's
the result.
I have retained the old behavior of the CONF_* functions, and have
added a more "object oriented" interface through NCONF_* functions
(New CONF, you see :-)), working the same way as, for example, the
BIO interface. Really, the CONF_* are rewritten so they use the
NCONF_* functions internally.
In addition to that, I've split the old conf.c code into two files,
conf_def.c and conf_api.c. conf_def.c contains the default config
object that reads a configuration file the standard OpenSSL way, as
well as configuration file with Win32 registry file syntax (I'm not
sure I got that one right). conf_api.c provides an API to build other
configuration file readers around (can you see a configuraion file in
XML? I can :-)).
Finally, I've changed the name conf_lcl.h to conf_def.h, since it's
made specifically for that "class" and none others.
2000-04-09 20:04:35 +08:00
|
|
|
#include "conf_def.h"
|
1999-04-24 06:13:45 +08:00
|
|
|
#include <openssl/buffer.h>
|
|
|
|
#include <openssl/err.h>
|
2018-02-27 20:55:35 +08:00
|
|
|
#ifndef OPENSSL_NO_POSIX_IO
|
|
|
|
# include <sys/stat.h>
|
|
|
|
# ifdef _WIN32
|
|
|
|
# define stat _stat
|
|
|
|
# endif
|
|
|
|
#endif
|
1998-12-21 18:52:47 +08:00
|
|
|
|
2018-07-19 21:28:34 +08:00
|
|
|
#ifndef S_ISDIR
|
|
|
|
# define S_ISDIR(a) (((a) & S_IFMT) == S_IFDIR)
|
|
|
|
#endif
|
|
|
|
|
2017-03-10 18:51:35 +08:00
|
|
|
/*
|
|
|
|
* The maximum length we can grow a value to after variable expansion. 64k
|
|
|
|
* should be more than enough for all reasonable uses.
|
|
|
|
*/
|
|
|
|
#define MAX_CONF_VALUE_LENGTH 65536
|
|
|
|
|
2018-04-03 04:37:30 +08:00
|
|
|
static int is_keytype(const CONF *conf, char c, unsigned short type);
|
I've always wanted to make the CONF library more adaptable. Here's
the result.
I have retained the old behavior of the CONF_* functions, and have
added a more "object oriented" interface through NCONF_* functions
(New CONF, you see :-)), working the same way as, for example, the
BIO interface. Really, the CONF_* are rewritten so they use the
NCONF_* functions internally.
In addition to that, I've split the old conf.c code into two files,
conf_def.c and conf_api.c. conf_def.c contains the default config
object that reads a configuration file the standard OpenSSL way, as
well as configuration file with Win32 registry file syntax (I'm not
sure I got that one right). conf_api.c provides an API to build other
configuration file readers around (can you see a configuraion file in
XML? I can :-)).
Finally, I've changed the name conf_lcl.h to conf_def.h, since it's
made specifically for that "class" and none others.
2000-04-09 20:04:35 +08:00
|
|
|
static char *eat_ws(CONF *conf, char *p);
|
2018-02-27 20:55:35 +08:00
|
|
|
static void trim_ws(CONF *conf, char *start);
|
I've always wanted to make the CONF library more adaptable. Here's
the result.
I have retained the old behavior of the CONF_* functions, and have
added a more "object oriented" interface through NCONF_* functions
(New CONF, you see :-)), working the same way as, for example, the
BIO interface. Really, the CONF_* are rewritten so they use the
NCONF_* functions internally.
In addition to that, I've split the old conf.c code into two files,
conf_def.c and conf_api.c. conf_def.c contains the default config
object that reads a configuration file the standard OpenSSL way, as
well as configuration file with Win32 registry file syntax (I'm not
sure I got that one right). conf_api.c provides an API to build other
configuration file readers around (can you see a configuraion file in
XML? I can :-)).
Finally, I've changed the name conf_lcl.h to conf_def.h, since it's
made specifically for that "class" and none others.
2000-04-09 20:04:35 +08:00
|
|
|
static char *eat_alpha_numeric(CONF *conf, char *p);
|
|
|
|
static void clear_comments(CONF *conf, char *p);
|
|
|
|
static int str_copy(CONF *conf, char *section, char **to, char *from);
|
|
|
|
static char *scan_quote(CONF *conf, char *p);
|
|
|
|
static char *scan_dquote(CONF *conf, char *p);
|
2000-06-06 23:21:12 +08:00
|
|
|
#define scan_esc(conf,p) (((IS_EOF((conf),(p)[1]))?((p)+1):((p)+2)))
|
2018-02-27 20:55:35 +08:00
|
|
|
#ifndef OPENSSL_NO_POSIX_IO
|
|
|
|
static BIO *process_include(char *include, OPENSSL_DIR_CTX **dirctx,
|
|
|
|
char **dirpath);
|
|
|
|
static BIO *get_next_file(const char *path, OPENSSL_DIR_CTX **dirctx);
|
|
|
|
#endif
|
I've always wanted to make the CONF library more adaptable. Here's
the result.
I have retained the old behavior of the CONF_* functions, and have
added a more "object oriented" interface through NCONF_* functions
(New CONF, you see :-)), working the same way as, for example, the
BIO interface. Really, the CONF_* are rewritten so they use the
NCONF_* functions internally.
In addition to that, I've split the old conf.c code into two files,
conf_def.c and conf_api.c. conf_def.c contains the default config
object that reads a configuration file the standard OpenSSL way, as
well as configuration file with Win32 registry file syntax (I'm not
sure I got that one right). conf_api.c provides an API to build other
configuration file readers around (can you see a configuraion file in
XML? I can :-)).
Finally, I've changed the name conf_lcl.h to conf_def.h, since it's
made specifically for that "class" and none others.
2000-04-09 20:04:35 +08:00
|
|
|
|
|
|
|
static CONF *def_create(CONF_METHOD *meth);
|
|
|
|
static int def_init_default(CONF *conf);
|
2019-11-06 00:28:50 +08:00
|
|
|
#ifndef OPENSSL_NO_DEPRECATED_3_0
|
I've always wanted to make the CONF library more adaptable. Here's
the result.
I have retained the old behavior of the CONF_* functions, and have
added a more "object oriented" interface through NCONF_* functions
(New CONF, you see :-)), working the same way as, for example, the
BIO interface. Really, the CONF_* are rewritten so they use the
NCONF_* functions internally.
In addition to that, I've split the old conf.c code into two files,
conf_def.c and conf_api.c. conf_def.c contains the default config
object that reads a configuration file the standard OpenSSL way, as
well as configuration file with Win32 registry file syntax (I'm not
sure I got that one right). conf_api.c provides an API to build other
configuration file readers around (can you see a configuraion file in
XML? I can :-)).
Finally, I've changed the name conf_lcl.h to conf_def.h, since it's
made specifically for that "class" and none others.
2000-04-09 20:04:35 +08:00
|
|
|
static int def_init_WIN32(CONF *conf);
|
2019-08-13 04:55:25 +08:00
|
|
|
#endif
|
I've always wanted to make the CONF library more adaptable. Here's
the result.
I have retained the old behavior of the CONF_* functions, and have
added a more "object oriented" interface through NCONF_* functions
(New CONF, you see :-)), working the same way as, for example, the
BIO interface. Really, the CONF_* are rewritten so they use the
NCONF_* functions internally.
In addition to that, I've split the old conf.c code into two files,
conf_def.c and conf_api.c. conf_def.c contains the default config
object that reads a configuration file the standard OpenSSL way, as
well as configuration file with Win32 registry file syntax (I'm not
sure I got that one right). conf_api.c provides an API to build other
configuration file readers around (can you see a configuraion file in
XML? I can :-)).
Finally, I've changed the name conf_lcl.h to conf_def.h, since it's
made specifically for that "class" and none others.
2000-04-09 20:04:35 +08:00
|
|
|
static int def_destroy(CONF *conf);
|
|
|
|
static int def_destroy_data(CONF *conf);
|
2000-10-19 16:26:32 +08:00
|
|
|
static int def_load(CONF *conf, const char *name, long *eline);
|
|
|
|
static int def_load_bio(CONF *conf, BIO *bp, long *eline);
|
2002-01-19 00:51:05 +08:00
|
|
|
static int def_dump(const CONF *conf, BIO *bp);
|
|
|
|
static int def_is_number(const CONF *conf, char c);
|
|
|
|
static int def_to_int(const CONF *conf, char c);
|
I've always wanted to make the CONF library more adaptable. Here's
the result.
I have retained the old behavior of the CONF_* functions, and have
added a more "object oriented" interface through NCONF_* functions
(New CONF, you see :-)), working the same way as, for example, the
BIO interface. Really, the CONF_* are rewritten so they use the
NCONF_* functions internally.
In addition to that, I've split the old conf.c code into two files,
conf_def.c and conf_api.c. conf_def.c contains the default config
object that reads a configuration file the standard OpenSSL way, as
well as configuration file with Win32 registry file syntax (I'm not
sure I got that one right). conf_api.c provides an API to build other
configuration file readers around (can you see a configuraion file in
XML? I can :-)).
Finally, I've changed the name conf_lcl.h to conf_def.h, since it's
made specifically for that "class" and none others.
2000-04-09 20:04:35 +08:00
|
|
|
|
|
|
|
static CONF_METHOD default_method = {
|
|
|
|
"OpenSSL default",
|
|
|
|
def_create,
|
|
|
|
def_init_default,
|
|
|
|
def_destroy,
|
|
|
|
def_destroy_data,
|
2000-10-19 16:26:32 +08:00
|
|
|
def_load_bio,
|
I've always wanted to make the CONF library more adaptable. Here's
the result.
I have retained the old behavior of the CONF_* functions, and have
added a more "object oriented" interface through NCONF_* functions
(New CONF, you see :-)), working the same way as, for example, the
BIO interface. Really, the CONF_* are rewritten so they use the
NCONF_* functions internally.
In addition to that, I've split the old conf.c code into two files,
conf_def.c and conf_api.c. conf_def.c contains the default config
object that reads a configuration file the standard OpenSSL way, as
well as configuration file with Win32 registry file syntax (I'm not
sure I got that one right). conf_api.c provides an API to build other
configuration file readers around (can you see a configuraion file in
XML? I can :-)).
Finally, I've changed the name conf_lcl.h to conf_def.h, since it's
made specifically for that "class" and none others.
2000-04-09 20:04:35 +08:00
|
|
|
def_dump,
|
|
|
|
def_is_number,
|
2000-10-19 16:29:27 +08:00
|
|
|
def_to_int,
|
|
|
|
def_load
|
I've always wanted to make the CONF library more adaptable. Here's
the result.
I have retained the old behavior of the CONF_* functions, and have
added a more "object oriented" interface through NCONF_* functions
(New CONF, you see :-)), working the same way as, for example, the
BIO interface. Really, the CONF_* are rewritten so they use the
NCONF_* functions internally.
In addition to that, I've split the old conf.c code into two files,
conf_def.c and conf_api.c. conf_def.c contains the default config
object that reads a configuration file the standard OpenSSL way, as
well as configuration file with Win32 registry file syntax (I'm not
sure I got that one right). conf_api.c provides an API to build other
configuration file readers around (can you see a configuraion file in
XML? I can :-)).
Finally, I've changed the name conf_lcl.h to conf_def.h, since it's
made specifically for that "class" and none others.
2000-04-09 20:04:35 +08:00
|
|
|
};
|
|
|
|
|
2019-08-13 04:55:25 +08:00
|
|
|
CONF_METHOD *NCONF_default(void)
|
|
|
|
{
|
|
|
|
return &default_method;
|
|
|
|
}
|
|
|
|
|
2019-11-06 00:28:50 +08:00
|
|
|
#ifndef OPENSSL_NO_DEPRECATED_3_0
|
I've always wanted to make the CONF library more adaptable. Here's
the result.
I have retained the old behavior of the CONF_* functions, and have
added a more "object oriented" interface through NCONF_* functions
(New CONF, you see :-)), working the same way as, for example, the
BIO interface. Really, the CONF_* are rewritten so they use the
NCONF_* functions internally.
In addition to that, I've split the old conf.c code into two files,
conf_def.c and conf_api.c. conf_def.c contains the default config
object that reads a configuration file the standard OpenSSL way, as
well as configuration file with Win32 registry file syntax (I'm not
sure I got that one right). conf_api.c provides an API to build other
configuration file readers around (can you see a configuraion file in
XML? I can :-)).
Finally, I've changed the name conf_lcl.h to conf_def.h, since it's
made specifically for that "class" and none others.
2000-04-09 20:04:35 +08:00
|
|
|
static CONF_METHOD WIN32_method = {
|
|
|
|
"WIN32",
|
|
|
|
def_create,
|
|
|
|
def_init_WIN32,
|
|
|
|
def_destroy,
|
|
|
|
def_destroy_data,
|
2000-10-19 16:26:32 +08:00
|
|
|
def_load_bio,
|
I've always wanted to make the CONF library more adaptable. Here's
the result.
I have retained the old behavior of the CONF_* functions, and have
added a more "object oriented" interface through NCONF_* functions
(New CONF, you see :-)), working the same way as, for example, the
BIO interface. Really, the CONF_* are rewritten so they use the
NCONF_* functions internally.
In addition to that, I've split the old conf.c code into two files,
conf_def.c and conf_api.c. conf_def.c contains the default config
object that reads a configuration file the standard OpenSSL way, as
well as configuration file with Win32 registry file syntax (I'm not
sure I got that one right). conf_api.c provides an API to build other
configuration file readers around (can you see a configuraion file in
XML? I can :-)).
Finally, I've changed the name conf_lcl.h to conf_def.h, since it's
made specifically for that "class" and none others.
2000-04-09 20:04:35 +08:00
|
|
|
def_dump,
|
|
|
|
def_is_number,
|
2000-10-19 16:29:27 +08:00
|
|
|
def_to_int,
|
|
|
|
def_load
|
I've always wanted to make the CONF library more adaptable. Here's
the result.
I have retained the old behavior of the CONF_* functions, and have
added a more "object oriented" interface through NCONF_* functions
(New CONF, you see :-)), working the same way as, for example, the
BIO interface. Really, the CONF_* are rewritten so they use the
NCONF_* functions internally.
In addition to that, I've split the old conf.c code into two files,
conf_def.c and conf_api.c. conf_def.c contains the default config
object that reads a configuration file the standard OpenSSL way, as
well as configuration file with Win32 registry file syntax (I'm not
sure I got that one right). conf_api.c provides an API to build other
configuration file readers around (can you see a configuraion file in
XML? I can :-)).
Finally, I've changed the name conf_lcl.h to conf_def.h, since it's
made specifically for that "class" and none others.
2000-04-09 20:04:35 +08:00
|
|
|
};
|
|
|
|
|
2018-05-09 23:09:50 +08:00
|
|
|
CONF_METHOD *NCONF_WIN32(void)
|
I've always wanted to make the CONF library more adaptable. Here's
the result.
I have retained the old behavior of the CONF_* functions, and have
added a more "object oriented" interface through NCONF_* functions
(New CONF, you see :-)), working the same way as, for example, the
BIO interface. Really, the CONF_* are rewritten so they use the
NCONF_* functions internally.
In addition to that, I've split the old conf.c code into two files,
conf_def.c and conf_api.c. conf_def.c contains the default config
object that reads a configuration file the standard OpenSSL way, as
well as configuration file with Win32 registry file syntax (I'm not
sure I got that one right). conf_api.c provides an API to build other
configuration file readers around (can you see a configuraion file in
XML? I can :-)).
Finally, I've changed the name conf_lcl.h to conf_def.h, since it's
made specifically for that "class" and none others.
2000-04-09 20:04:35 +08:00
|
|
|
{
|
|
|
|
return &WIN32_method;
|
|
|
|
}
|
2019-08-13 04:55:25 +08:00
|
|
|
#endif
|
1998-12-21 18:52:47 +08:00
|
|
|
|
I've always wanted to make the CONF library more adaptable. Here's
the result.
I have retained the old behavior of the CONF_* functions, and have
added a more "object oriented" interface through NCONF_* functions
(New CONF, you see :-)), working the same way as, for example, the
BIO interface. Really, the CONF_* are rewritten so they use the
NCONF_* functions internally.
In addition to that, I've split the old conf.c code into two files,
conf_def.c and conf_api.c. conf_def.c contains the default config
object that reads a configuration file the standard OpenSSL way, as
well as configuration file with Win32 registry file syntax (I'm not
sure I got that one right). conf_api.c provides an API to build other
configuration file readers around (can you see a configuraion file in
XML? I can :-)).
Finally, I've changed the name conf_lcl.h to conf_def.h, since it's
made specifically for that "class" and none others.
2000-04-09 20:04:35 +08:00
|
|
|
static CONF *def_create(CONF_METHOD *meth)
|
|
|
|
{
|
|
|
|
CONF *ret;
|
2015-01-22 11:40:55 +08:00
|
|
|
|
2015-05-02 11:10:31 +08:00
|
|
|
ret = OPENSSL_malloc(sizeof(*ret));
|
2015-10-30 19:12:26 +08:00
|
|
|
if (ret != NULL)
|
I've always wanted to make the CONF library more adaptable. Here's
the result.
I have retained the old behavior of the CONF_* functions, and have
added a more "object oriented" interface through NCONF_* functions
(New CONF, you see :-)), working the same way as, for example, the
BIO interface. Really, the CONF_* are rewritten so they use the
NCONF_* functions internally.
In addition to that, I've split the old conf.c code into two files,
conf_def.c and conf_api.c. conf_def.c contains the default config
object that reads a configuration file the standard OpenSSL way, as
well as configuration file with Win32 registry file syntax (I'm not
sure I got that one right). conf_api.c provides an API to build other
configuration file readers around (can you see a configuraion file in
XML? I can :-)).
Finally, I've changed the name conf_lcl.h to conf_def.h, since it's
made specifically for that "class" and none others.
2000-04-09 20:04:35 +08:00
|
|
|
if (meth->init(ret) == 0) {
|
2000-06-02 06:19:21 +08:00
|
|
|
OPENSSL_free(ret);
|
I've always wanted to make the CONF library more adaptable. Here's
the result.
I have retained the old behavior of the CONF_* functions, and have
added a more "object oriented" interface through NCONF_* functions
(New CONF, you see :-)), working the same way as, for example, the
BIO interface. Really, the CONF_* are rewritten so they use the
NCONF_* functions internally.
In addition to that, I've split the old conf.c code into two files,
conf_def.c and conf_api.c. conf_def.c contains the default config
object that reads a configuration file the standard OpenSSL way, as
well as configuration file with Win32 registry file syntax (I'm not
sure I got that one right). conf_api.c provides an API to build other
configuration file readers around (can you see a configuraion file in
XML? I can :-)).
Finally, I've changed the name conf_lcl.h to conf_def.h, since it's
made specifically for that "class" and none others.
2000-04-09 20:04:35 +08:00
|
|
|
ret = NULL;
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
2015-01-22 11:40:55 +08:00
|
|
|
|
I've always wanted to make the CONF library more adaptable. Here's
the result.
I have retained the old behavior of the CONF_* functions, and have
added a more "object oriented" interface through NCONF_* functions
(New CONF, you see :-)), working the same way as, for example, the
BIO interface. Really, the CONF_* are rewritten so they use the
NCONF_* functions internally.
In addition to that, I've split the old conf.c code into two files,
conf_def.c and conf_api.c. conf_def.c contains the default config
object that reads a configuration file the standard OpenSSL way, as
well as configuration file with Win32 registry file syntax (I'm not
sure I got that one right). conf_api.c provides an API to build other
configuration file readers around (can you see a configuraion file in
XML? I can :-)).
Finally, I've changed the name conf_lcl.h to conf_def.h, since it's
made specifically for that "class" and none others.
2000-04-09 20:04:35 +08:00
|
|
|
static int def_init_default(CONF *conf)
|
|
|
|
{
|
|
|
|
if (conf == NULL)
|
|
|
|
return 0;
|
|
|
|
|
2019-11-13 01:16:14 +08:00
|
|
|
memset(conf, 0, sizeof(*conf));
|
I've always wanted to make the CONF library more adaptable. Here's
the result.
I have retained the old behavior of the CONF_* functions, and have
added a more "object oriented" interface through NCONF_* functions
(New CONF, you see :-)), working the same way as, for example, the
BIO interface. Really, the CONF_* are rewritten so they use the
NCONF_* functions internally.
In addition to that, I've split the old conf.c code into two files,
conf_def.c and conf_api.c. conf_def.c contains the default config
object that reads a configuration file the standard OpenSSL way, as
well as configuration file with Win32 registry file syntax (I'm not
sure I got that one right). conf_api.c provides an API to build other
configuration file readers around (can you see a configuraion file in
XML? I can :-)).
Finally, I've changed the name conf_lcl.h to conf_def.h, since it's
made specifically for that "class" and none others.
2000-04-09 20:04:35 +08:00
|
|
|
conf->meth = &default_method;
|
2014-08-26 08:07:57 +08:00
|
|
|
conf->meth_data = (void *)CONF_type_default;
|
1998-12-21 18:52:47 +08:00
|
|
|
|
I've always wanted to make the CONF library more adaptable. Here's
the result.
I have retained the old behavior of the CONF_* functions, and have
added a more "object oriented" interface through NCONF_* functions
(New CONF, you see :-)), working the same way as, for example, the
BIO interface. Really, the CONF_* are rewritten so they use the
NCONF_* functions internally.
In addition to that, I've split the old conf.c code into two files,
conf_def.c and conf_api.c. conf_def.c contains the default config
object that reads a configuration file the standard OpenSSL way, as
well as configuration file with Win32 registry file syntax (I'm not
sure I got that one right). conf_api.c provides an API to build other
configuration file readers around (can you see a configuraion file in
XML? I can :-)).
Finally, I've changed the name conf_lcl.h to conf_def.h, since it's
made specifically for that "class" and none others.
2000-04-09 20:04:35 +08:00
|
|
|
return 1;
|
|
|
|
}
|
1999-06-21 01:36:11 +08:00
|
|
|
|
2019-11-06 00:28:50 +08:00
|
|
|
#ifndef OPENSSL_NO_DEPRECATED_3_0
|
I've always wanted to make the CONF library more adaptable. Here's
the result.
I have retained the old behavior of the CONF_* functions, and have
added a more "object oriented" interface through NCONF_* functions
(New CONF, you see :-)), working the same way as, for example, the
BIO interface. Really, the CONF_* are rewritten so they use the
NCONF_* functions internally.
In addition to that, I've split the old conf.c code into two files,
conf_def.c and conf_api.c. conf_def.c contains the default config
object that reads a configuration file the standard OpenSSL way, as
well as configuration file with Win32 registry file syntax (I'm not
sure I got that one right). conf_api.c provides an API to build other
configuration file readers around (can you see a configuraion file in
XML? I can :-)).
Finally, I've changed the name conf_lcl.h to conf_def.h, since it's
made specifically for that "class" and none others.
2000-04-09 20:04:35 +08:00
|
|
|
static int def_init_WIN32(CONF *conf)
|
1998-12-21 18:52:47 +08:00
|
|
|
{
|
I've always wanted to make the CONF library more adaptable. Here's
the result.
I have retained the old behavior of the CONF_* functions, and have
added a more "object oriented" interface through NCONF_* functions
(New CONF, you see :-)), working the same way as, for example, the
BIO interface. Really, the CONF_* are rewritten so they use the
NCONF_* functions internally.
In addition to that, I've split the old conf.c code into two files,
conf_def.c and conf_api.c. conf_def.c contains the default config
object that reads a configuration file the standard OpenSSL way, as
well as configuration file with Win32 registry file syntax (I'm not
sure I got that one right). conf_api.c provides an API to build other
configuration file readers around (can you see a configuraion file in
XML? I can :-)).
Finally, I've changed the name conf_lcl.h to conf_def.h, since it's
made specifically for that "class" and none others.
2000-04-09 20:04:35 +08:00
|
|
|
if (conf == NULL)
|
|
|
|
return 0;
|
1999-06-21 01:36:11 +08:00
|
|
|
|
2019-11-13 01:16:14 +08:00
|
|
|
memset(conf, 0, sizeof(*conf));
|
I've always wanted to make the CONF library more adaptable. Here's
the result.
I have retained the old behavior of the CONF_* functions, and have
added a more "object oriented" interface through NCONF_* functions
(New CONF, you see :-)), working the same way as, for example, the
BIO interface. Really, the CONF_* are rewritten so they use the
NCONF_* functions internally.
In addition to that, I've split the old conf.c code into two files,
conf_def.c and conf_api.c. conf_def.c contains the default config
object that reads a configuration file the standard OpenSSL way, as
well as configuration file with Win32 registry file syntax (I'm not
sure I got that one right). conf_api.c provides an API to build other
configuration file readers around (can you see a configuraion file in
XML? I can :-)).
Finally, I've changed the name conf_lcl.h to conf_def.h, since it's
made specifically for that "class" and none others.
2000-04-09 20:04:35 +08:00
|
|
|
conf->meth = &WIN32_method;
|
|
|
|
conf->meth_data = (void *)CONF_type_win32;
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
2019-08-13 04:55:25 +08:00
|
|
|
#endif
|
I've always wanted to make the CONF library more adaptable. Here's
the result.
I have retained the old behavior of the CONF_* functions, and have
added a more "object oriented" interface through NCONF_* functions
(New CONF, you see :-)), working the same way as, for example, the
BIO interface. Really, the CONF_* are rewritten so they use the
NCONF_* functions internally.
In addition to that, I've split the old conf.c code into two files,
conf_def.c and conf_api.c. conf_def.c contains the default config
object that reads a configuration file the standard OpenSSL way, as
well as configuration file with Win32 registry file syntax (I'm not
sure I got that one right). conf_api.c provides an API to build other
configuration file readers around (can you see a configuraion file in
XML? I can :-)).
Finally, I've changed the name conf_lcl.h to conf_def.h, since it's
made specifically for that "class" and none others.
2000-04-09 20:04:35 +08:00
|
|
|
|
|
|
|
static int def_destroy(CONF *conf)
|
|
|
|
{
|
|
|
|
if (def_destroy_data(conf)) {
|
2000-06-02 06:19:21 +08:00
|
|
|
OPENSSL_free(conf);
|
I've always wanted to make the CONF library more adaptable. Here's
the result.
I have retained the old behavior of the CONF_* functions, and have
added a more "object oriented" interface through NCONF_* functions
(New CONF, you see :-)), working the same way as, for example, the
BIO interface. Really, the CONF_* are rewritten so they use the
NCONF_* functions internally.
In addition to that, I've split the old conf.c code into two files,
conf_def.c and conf_api.c. conf_def.c contains the default config
object that reads a configuration file the standard OpenSSL way, as
well as configuration file with Win32 registry file syntax (I'm not
sure I got that one right). conf_api.c provides an API to build other
configuration file readers around (can you see a configuraion file in
XML? I can :-)).
Finally, I've changed the name conf_lcl.h to conf_def.h, since it's
made specifically for that "class" and none others.
2000-04-09 20:04:35 +08:00
|
|
|
return 1;
|
1999-06-21 01:36:11 +08:00
|
|
|
}
|
I've always wanted to make the CONF library more adaptable. Here's
the result.
I have retained the old behavior of the CONF_* functions, and have
added a more "object oriented" interface through NCONF_* functions
(New CONF, you see :-)), working the same way as, for example, the
BIO interface. Really, the CONF_* are rewritten so they use the
NCONF_* functions internally.
In addition to that, I've split the old conf.c code into two files,
conf_def.c and conf_api.c. conf_def.c contains the default config
object that reads a configuration file the standard OpenSSL way, as
well as configuration file with Win32 registry file syntax (I'm not
sure I got that one right). conf_api.c provides an API to build other
configuration file readers around (can you see a configuraion file in
XML? I can :-)).
Finally, I've changed the name conf_lcl.h to conf_def.h, since it's
made specifically for that "class" and none others.
2000-04-09 20:04:35 +08:00
|
|
|
return 0;
|
|
|
|
}
|
1999-06-21 01:36:11 +08:00
|
|
|
|
I've always wanted to make the CONF library more adaptable. Here's
the result.
I have retained the old behavior of the CONF_* functions, and have
added a more "object oriented" interface through NCONF_* functions
(New CONF, you see :-)), working the same way as, for example, the
BIO interface. Really, the CONF_* are rewritten so they use the
NCONF_* functions internally.
In addition to that, I've split the old conf.c code into two files,
conf_def.c and conf_api.c. conf_def.c contains the default config
object that reads a configuration file the standard OpenSSL way, as
well as configuration file with Win32 registry file syntax (I'm not
sure I got that one right). conf_api.c provides an API to build other
configuration file readers around (can you see a configuraion file in
XML? I can :-)).
Finally, I've changed the name conf_lcl.h to conf_def.h, since it's
made specifically for that "class" and none others.
2000-04-09 20:04:35 +08:00
|
|
|
static int def_destroy_data(CONF *conf)
|
|
|
|
{
|
|
|
|
if (conf == NULL)
|
|
|
|
return 0;
|
|
|
|
_CONF_free_data(conf);
|
|
|
|
return 1;
|
1999-06-21 01:36:11 +08:00
|
|
|
}
|
|
|
|
|
2000-10-19 16:26:32 +08:00
|
|
|
static int def_load(CONF *conf, const char *name, long *line)
|
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
BIO *in = NULL;
|
|
|
|
|
2001-02-20 16:13:47 +08:00
|
|
|
#ifdef OPENSSL_SYS_VMS
|
2000-10-19 16:26:32 +08:00
|
|
|
in = BIO_new_file(name, "r");
|
|
|
|
#else
|
|
|
|
in = BIO_new_file(name, "rb");
|
|
|
|
#endif
|
|
|
|
if (in == NULL) {
|
2002-01-25 00:16:43 +08:00
|
|
|
if (ERR_GET_REASON(ERR_peek_last_error()) == BIO_R_NO_SUCH_FILE)
|
2020-11-04 19:23:19 +08:00
|
|
|
ERR_raise(ERR_LIB_CONF, CONF_R_NO_SUCH_FILE);
|
2002-01-23 06:29:58 +08:00
|
|
|
else
|
2020-11-04 19:23:19 +08:00
|
|
|
ERR_raise(ERR_LIB_CONF, ERR_R_SYS_LIB);
|
2000-10-19 16:26:32 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = def_load_bio(conf, in, line);
|
|
|
|
BIO_free(in);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2021-04-30 04:22:30 +08:00
|
|
|
|
|
|
|
/* Parse a boolean value and fill in *flag. Return 0 on error. */
|
|
|
|
static int parsebool(const char *pval, int *flag)
|
|
|
|
{
|
2022-04-12 18:30:08 +08:00
|
|
|
if (OPENSSL_strcasecmp(pval, "on") == 0
|
|
|
|
|| OPENSSL_strcasecmp(pval, "true") == 0) {
|
2021-04-30 04:22:30 +08:00
|
|
|
*flag = 1;
|
2022-04-12 18:30:08 +08:00
|
|
|
} else if (OPENSSL_strcasecmp(pval, "off") == 0
|
|
|
|
|| OPENSSL_strcasecmp(pval, "false") == 0) {
|
2021-04-30 04:22:30 +08:00
|
|
|
*flag = 0;
|
|
|
|
} else {
|
|
|
|
ERR_raise(ERR_LIB_CONF, CONF_R_INVALID_PRAGMA);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2000-10-19 16:26:32 +08:00
|
|
|
static int def_load_bio(CONF *conf, BIO *in, long *line)
|
1999-06-21 01:36:11 +08:00
|
|
|
{
|
2002-10-09 21:40:48 +08:00
|
|
|
/* The macro BUFSIZE conflicts with a system macro in VxWorks */
|
|
|
|
#define CONFBUFSIZE 512
|
1998-12-21 18:52:47 +08:00
|
|
|
int bufnum = 0, i, ii;
|
|
|
|
BUF_MEM *buff = NULL;
|
|
|
|
char *s, *p, *end;
|
2010-06-12 22:13:23 +08:00
|
|
|
int again;
|
2021-01-13 15:51:39 +08:00
|
|
|
int first_call = 1;
|
1998-12-21 19:00:56 +08:00
|
|
|
long eline = 0;
|
2002-07-30 21:04:04 +08:00
|
|
|
char btmp[DECIMAL_SIZE(eline) + 1];
|
I've always wanted to make the CONF library more adaptable. Here's
the result.
I have retained the old behavior of the CONF_* functions, and have
added a more "object oriented" interface through NCONF_* functions
(New CONF, you see :-)), working the same way as, for example, the
BIO interface. Really, the CONF_* are rewritten so they use the
NCONF_* functions internally.
In addition to that, I've split the old conf.c code into two files,
conf_def.c and conf_api.c. conf_def.c contains the default config
object that reads a configuration file the standard OpenSSL way, as
well as configuration file with Win32 registry file syntax (I'm not
sure I got that one right). conf_api.c provides an API to build other
configuration file readers around (can you see a configuraion file in
XML? I can :-)).
Finally, I've changed the name conf_lcl.h to conf_def.h, since it's
made specifically for that "class" and none others.
2000-04-09 20:04:35 +08:00
|
|
|
CONF_VALUE *v = NULL, *tv;
|
1998-12-21 18:52:47 +08:00
|
|
|
CONF_VALUE *sv = NULL;
|
|
|
|
char *section = NULL, *buf;
|
|
|
|
char *start, *psection, *pname;
|
I've always wanted to make the CONF library more adaptable. Here's
the result.
I have retained the old behavior of the CONF_* functions, and have
added a more "object oriented" interface through NCONF_* functions
(New CONF, you see :-)), working the same way as, for example, the
BIO interface. Really, the CONF_* are rewritten so they use the
NCONF_* functions internally.
In addition to that, I've split the old conf.c code into two files,
conf_def.c and conf_api.c. conf_def.c contains the default config
object that reads a configuration file the standard OpenSSL way, as
well as configuration file with Win32 registry file syntax (I'm not
sure I got that one right). conf_api.c provides an API to build other
configuration file readers around (can you see a configuraion file in
XML? I can :-)).
Finally, I've changed the name conf_lcl.h to conf_def.h, since it's
made specifically for that "class" and none others.
2000-04-09 20:04:35 +08:00
|
|
|
void *h = (void *)(conf->data);
|
2018-02-27 20:55:35 +08:00
|
|
|
STACK_OF(BIO) *biosk = NULL;
|
|
|
|
#ifndef OPENSSL_NO_POSIX_IO
|
|
|
|
char *dirpath = NULL;
|
|
|
|
OPENSSL_DIR_CTX *dirctx = NULL;
|
|
|
|
#endif
|
2023-04-26 22:04:42 +08:00
|
|
|
#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
|
|
|
|
int numincludes = 0;
|
|
|
|
#endif
|
2015-01-22 11:40:55 +08:00
|
|
|
|
1998-12-21 18:52:47 +08:00
|
|
|
if ((buff = BUF_MEM_new()) == NULL) {
|
2020-11-04 19:23:19 +08:00
|
|
|
ERR_raise(ERR_LIB_CONF, ERR_R_BUF_LIB);
|
1998-12-21 18:52:47 +08:00
|
|
|
goto err;
|
|
|
|
}
|
2015-01-22 11:40:55 +08:00
|
|
|
|
Rename some BUF_xxx to OPENSSL_xxx
Rename BUF_{strdup,strlcat,strlcpy,memdup,strndup,strnlen}
to OPENSSL_{strdup,strlcat,strlcpy,memdup,strndup,strnlen}
Add #define's for the old names.
Add CRYPTO_{memdup,strndup}, called by OPENSSL_{memdup,strndup} macros.
Reviewed-by: Tim Hudson <tjh@openssl.org>
2015-12-17 05:12:24 +08:00
|
|
|
section = OPENSSL_strdup("default");
|
2022-09-29 19:57:34 +08:00
|
|
|
if (section == NULL)
|
1998-12-21 18:52:47 +08:00
|
|
|
goto err;
|
2015-01-22 11:40:55 +08:00
|
|
|
|
I've always wanted to make the CONF library more adaptable. Here's
the result.
I have retained the old behavior of the CONF_* functions, and have
added a more "object oriented" interface through NCONF_* functions
(New CONF, you see :-)), working the same way as, for example, the
BIO interface. Really, the CONF_* are rewritten so they use the
NCONF_* functions internally.
In addition to that, I've split the old conf.c code into two files,
conf_def.c and conf_api.c. conf_def.c contains the default config
object that reads a configuration file the standard OpenSSL way, as
well as configuration file with Win32 registry file syntax (I'm not
sure I got that one right). conf_api.c provides an API to build other
configuration file readers around (can you see a configuraion file in
XML? I can :-)).
Finally, I've changed the name conf_lcl.h to conf_def.h, since it's
made specifically for that "class" and none others.
2000-04-09 20:04:35 +08:00
|
|
|
if (_CONF_new_data(conf) == 0) {
|
2022-09-29 19:57:34 +08:00
|
|
|
ERR_raise(ERR_LIB_CONF, ERR_R_CONF_LIB);
|
I've always wanted to make the CONF library more adaptable. Here's
the result.
I have retained the old behavior of the CONF_* functions, and have
added a more "object oriented" interface through NCONF_* functions
(New CONF, you see :-)), working the same way as, for example, the
BIO interface. Really, the CONF_* are rewritten so they use the
NCONF_* functions internally.
In addition to that, I've split the old conf.c code into two files,
conf_def.c and conf_api.c. conf_def.c contains the default config
object that reads a configuration file the standard OpenSSL way, as
well as configuration file with Win32 registry file syntax (I'm not
sure I got that one right). conf_api.c provides an API to build other
configuration file readers around (can you see a configuraion file in
XML? I can :-)).
Finally, I've changed the name conf_lcl.h to conf_def.h, since it's
made specifically for that "class" and none others.
2000-04-09 20:04:35 +08:00
|
|
|
goto err;
|
1998-12-21 18:52:47 +08:00
|
|
|
}
|
2015-01-22 11:40:55 +08:00
|
|
|
|
I've always wanted to make the CONF library more adaptable. Here's
the result.
I have retained the old behavior of the CONF_* functions, and have
added a more "object oriented" interface through NCONF_* functions
(New CONF, you see :-)), working the same way as, for example, the
BIO interface. Really, the CONF_* are rewritten so they use the
NCONF_* functions internally.
In addition to that, I've split the old conf.c code into two files,
conf_def.c and conf_api.c. conf_def.c contains the default config
object that reads a configuration file the standard OpenSSL way, as
well as configuration file with Win32 registry file syntax (I'm not
sure I got that one right). conf_api.c provides an API to build other
configuration file readers around (can you see a configuraion file in
XML? I can :-)).
Finally, I've changed the name conf_lcl.h to conf_def.h, since it's
made specifically for that "class" and none others.
2000-04-09 20:04:35 +08:00
|
|
|
sv = _CONF_new_section(conf, section);
|
1998-12-21 18:52:47 +08:00
|
|
|
if (sv == NULL) {
|
2020-11-04 19:23:19 +08:00
|
|
|
ERR_raise(ERR_LIB_CONF, CONF_R_UNABLE_TO_CREATE_NEW_SECTION);
|
1998-12-21 18:52:47 +08:00
|
|
|
goto err;
|
|
|
|
}
|
2015-01-22 11:40:55 +08:00
|
|
|
|
1998-12-21 18:52:47 +08:00
|
|
|
bufnum = 0;
|
2002-11-14 14:51:18 +08:00
|
|
|
again = 0;
|
1998-12-21 18:52:47 +08:00
|
|
|
for (;;) {
|
2002-10-09 21:40:48 +08:00
|
|
|
if (!BUF_MEM_grow(buff, bufnum + CONFBUFSIZE)) {
|
2020-11-04 19:23:19 +08:00
|
|
|
ERR_raise(ERR_LIB_CONF, ERR_R_BUF_LIB);
|
1998-12-21 18:52:47 +08:00
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
p = &(buff->data[bufnum]);
|
|
|
|
*p = '\0';
|
2018-02-27 20:55:35 +08:00
|
|
|
read_retry:
|
2020-12-11 04:02:47 +08:00
|
|
|
if (in != NULL && BIO_gets(in, p, CONFBUFSIZE - 1) < 0)
|
|
|
|
goto err;
|
2002-10-09 21:40:48 +08:00
|
|
|
p[CONFBUFSIZE - 1] = '\0';
|
1998-12-21 18:52:47 +08:00
|
|
|
ii = i = strlen(p);
|
2021-01-13 15:51:39 +08:00
|
|
|
if (first_call) {
|
|
|
|
/* Other BOMs imply unsupported multibyte encoding,
|
|
|
|
* so don't strip them and let the error raise */
|
|
|
|
const unsigned char utf8_bom[3] = {0xEF, 0xBB, 0xBF};
|
|
|
|
|
|
|
|
if (i >= 3 && memcmp(p, utf8_bom, 3) == 0) {
|
|
|
|
memmove(p, p + 3, i - 3);
|
|
|
|
p[i - 3] = 0;
|
|
|
|
i -= 3;
|
|
|
|
ii -= 3;
|
|
|
|
}
|
|
|
|
first_call = 0;
|
|
|
|
}
|
2018-02-27 20:55:35 +08:00
|
|
|
if (i == 0 && !again) {
|
2020-12-11 04:02:47 +08:00
|
|
|
/* the currently processed BIO is NULL or at EOF */
|
2018-02-27 20:55:35 +08:00
|
|
|
BIO *parent;
|
|
|
|
|
|
|
|
#ifndef OPENSSL_NO_POSIX_IO
|
|
|
|
/* continue processing with the next file from directory */
|
|
|
|
if (dirctx != NULL) {
|
|
|
|
BIO *next;
|
|
|
|
|
|
|
|
if ((next = get_next_file(dirpath, &dirctx)) != NULL) {
|
|
|
|
BIO_vfree(in);
|
|
|
|
in = next;
|
|
|
|
goto read_retry;
|
|
|
|
} else {
|
|
|
|
OPENSSL_free(dirpath);
|
|
|
|
dirpath = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
/* no more files in directory, continue with processing parent */
|
2022-10-12 16:36:20 +08:00
|
|
|
if ((parent = sk_BIO_pop(biosk)) == NULL) {
|
2018-02-27 20:55:35 +08:00
|
|
|
/* everything processed get out of the loop */
|
|
|
|
break;
|
|
|
|
} else {
|
|
|
|
BIO_vfree(in);
|
|
|
|
in = parent;
|
|
|
|
goto read_retry;
|
|
|
|
}
|
|
|
|
}
|
2002-11-14 14:51:18 +08:00
|
|
|
again = 0;
|
1998-12-21 18:52:47 +08:00
|
|
|
while (i > 0) {
|
|
|
|
if ((p[i - 1] != '\r') && (p[i - 1] != '\n'))
|
|
|
|
break;
|
|
|
|
else
|
|
|
|
i--;
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
* we removed some trailing stuff so there is a new line on the end.
|
|
|
|
*/
|
2002-11-14 14:51:18 +08:00
|
|
|
if (ii && i == ii)
|
1998-12-21 18:52:47 +08:00
|
|
|
again = 1; /* long line */
|
|
|
|
else {
|
|
|
|
p[i] = '\0';
|
|
|
|
eline++; /* another input line */
|
|
|
|
}
|
2015-01-22 11:40:55 +08:00
|
|
|
|
1998-12-21 18:52:47 +08:00
|
|
|
/* we now have a line with trailing \r\n removed */
|
2015-01-22 11:40:55 +08:00
|
|
|
|
1998-12-21 18:52:47 +08:00
|
|
|
/* i is the number of bytes */
|
|
|
|
bufnum += i;
|
2015-01-22 11:40:55 +08:00
|
|
|
|
1998-12-21 18:52:47 +08:00
|
|
|
v = NULL;
|
|
|
|
/* check for line continuation */
|
2024-07-15 18:16:09 +08:00
|
|
|
if (!again && bufnum >= 1) {
|
1998-12-21 18:52:47 +08:00
|
|
|
/*
|
|
|
|
* If we have bytes and the last char '\\' and second last char
|
|
|
|
* is not '\\'
|
|
|
|
*/
|
|
|
|
p = &(buff->data[bufnum - 1]);
|
I've always wanted to make the CONF library more adaptable. Here's
the result.
I have retained the old behavior of the CONF_* functions, and have
added a more "object oriented" interface through NCONF_* functions
(New CONF, you see :-)), working the same way as, for example, the
BIO interface. Really, the CONF_* are rewritten so they use the
NCONF_* functions internally.
In addition to that, I've split the old conf.c code into two files,
conf_def.c and conf_api.c. conf_def.c contains the default config
object that reads a configuration file the standard OpenSSL way, as
well as configuration file with Win32 registry file syntax (I'm not
sure I got that one right). conf_api.c provides an API to build other
configuration file readers around (can you see a configuraion file in
XML? I can :-)).
Finally, I've changed the name conf_lcl.h to conf_def.h, since it's
made specifically for that "class" and none others.
2000-04-09 20:04:35 +08:00
|
|
|
if (IS_ESC(conf, p[0]) && ((bufnum <= 1) || !IS_ESC(conf, p[-1]))) {
|
1998-12-21 18:52:47 +08:00
|
|
|
bufnum--;
|
|
|
|
again = 1;
|
|
|
|
}
|
2015-01-22 11:40:55 +08:00
|
|
|
}
|
1998-12-21 18:52:47 +08:00
|
|
|
if (again)
|
|
|
|
continue;
|
|
|
|
bufnum = 0;
|
|
|
|
buf = buff->data;
|
2015-01-22 11:40:55 +08:00
|
|
|
|
I've always wanted to make the CONF library more adaptable. Here's
the result.
I have retained the old behavior of the CONF_* functions, and have
added a more "object oriented" interface through NCONF_* functions
(New CONF, you see :-)), working the same way as, for example, the
BIO interface. Really, the CONF_* are rewritten so they use the
NCONF_* functions internally.
In addition to that, I've split the old conf.c code into two files,
conf_def.c and conf_api.c. conf_def.c contains the default config
object that reads a configuration file the standard OpenSSL way, as
well as configuration file with Win32 registry file syntax (I'm not
sure I got that one right). conf_api.c provides an API to build other
configuration file readers around (can you see a configuraion file in
XML? I can :-)).
Finally, I've changed the name conf_lcl.h to conf_def.h, since it's
made specifically for that "class" and none others.
2000-04-09 20:04:35 +08:00
|
|
|
clear_comments(conf, buf);
|
|
|
|
s = eat_ws(conf, buf);
|
|
|
|
if (IS_EOF(conf, *s))
|
|
|
|
continue; /* blank line */
|
1998-12-21 18:52:47 +08:00
|
|
|
if (*s == '[') {
|
1998-12-21 19:00:56 +08:00
|
|
|
char *ss;
|
2015-01-22 11:40:55 +08:00
|
|
|
|
1998-12-21 18:52:47 +08:00
|
|
|
s++;
|
I've always wanted to make the CONF library more adaptable. Here's
the result.
I have retained the old behavior of the CONF_* functions, and have
added a more "object oriented" interface through NCONF_* functions
(New CONF, you see :-)), working the same way as, for example, the
BIO interface. Really, the CONF_* are rewritten so they use the
NCONF_* functions internally.
In addition to that, I've split the old conf.c code into two files,
conf_def.c and conf_api.c. conf_def.c contains the default config
object that reads a configuration file the standard OpenSSL way, as
well as configuration file with Win32 registry file syntax (I'm not
sure I got that one right). conf_api.c provides an API to build other
configuration file readers around (can you see a configuraion file in
XML? I can :-)).
Finally, I've changed the name conf_lcl.h to conf_def.h, since it's
made specifically for that "class" and none others.
2000-04-09 20:04:35 +08:00
|
|
|
start = eat_ws(conf, s);
|
1998-12-21 19:00:56 +08:00
|
|
|
ss = start;
|
|
|
|
again:
|
I've always wanted to make the CONF library more adaptable. Here's
the result.
I have retained the old behavior of the CONF_* functions, and have
added a more "object oriented" interface through NCONF_* functions
(New CONF, you see :-)), working the same way as, for example, the
BIO interface. Really, the CONF_* are rewritten so they use the
NCONF_* functions internally.
In addition to that, I've split the old conf.c code into two files,
conf_def.c and conf_api.c. conf_def.c contains the default config
object that reads a configuration file the standard OpenSSL way, as
well as configuration file with Win32 registry file syntax (I'm not
sure I got that one right). conf_api.c provides an API to build other
configuration file readers around (can you see a configuraion file in
XML? I can :-)).
Finally, I've changed the name conf_lcl.h to conf_def.h, since it's
made specifically for that "class" and none others.
2000-04-09 20:04:35 +08:00
|
|
|
end = eat_alpha_numeric(conf, ss);
|
|
|
|
p = eat_ws(conf, end);
|
1998-12-21 18:52:47 +08:00
|
|
|
if (*p != ']') {
|
2014-07-07 20:11:48 +08:00
|
|
|
if (*p != '\0' && ss != p) {
|
1998-12-21 19:00:56 +08:00
|
|
|
ss = p;
|
|
|
|
goto again;
|
|
|
|
}
|
2020-11-04 19:23:19 +08:00
|
|
|
ERR_raise(ERR_LIB_CONF, CONF_R_MISSING_CLOSE_SQUARE_BRACKET);
|
1998-12-21 18:52:47 +08:00
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
*end = '\0';
|
I've always wanted to make the CONF library more adaptable. Here's
the result.
I have retained the old behavior of the CONF_* functions, and have
added a more "object oriented" interface through NCONF_* functions
(New CONF, you see :-)), working the same way as, for example, the
BIO interface. Really, the CONF_* are rewritten so they use the
NCONF_* functions internally.
In addition to that, I've split the old conf.c code into two files,
conf_def.c and conf_api.c. conf_def.c contains the default config
object that reads a configuration file the standard OpenSSL way, as
well as configuration file with Win32 registry file syntax (I'm not
sure I got that one right). conf_api.c provides an API to build other
configuration file readers around (can you see a configuraion file in
XML? I can :-)).
Finally, I've changed the name conf_lcl.h to conf_def.h, since it's
made specifically for that "class" and none others.
2000-04-09 20:04:35 +08:00
|
|
|
if (!str_copy(conf, NULL, §ion, start))
|
|
|
|
goto err;
|
|
|
|
if ((sv = _CONF_get_section(conf, section)) == NULL)
|
|
|
|
sv = _CONF_new_section(conf, section);
|
1998-12-21 18:52:47 +08:00
|
|
|
if (sv == NULL) {
|
2020-11-04 19:23:19 +08:00
|
|
|
ERR_raise(ERR_LIB_CONF, CONF_R_UNABLE_TO_CREATE_NEW_SECTION);
|
1998-12-21 18:52:47 +08:00
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
continue;
|
|
|
|
} else {
|
|
|
|
pname = s;
|
I've always wanted to make the CONF library more adaptable. Here's
the result.
I have retained the old behavior of the CONF_* functions, and have
added a more "object oriented" interface through NCONF_* functions
(New CONF, you see :-)), working the same way as, for example, the
BIO interface. Really, the CONF_* are rewritten so they use the
NCONF_* functions internally.
In addition to that, I've split the old conf.c code into two files,
conf_def.c and conf_api.c. conf_def.c contains the default config
object that reads a configuration file the standard OpenSSL way, as
well as configuration file with Win32 registry file syntax (I'm not
sure I got that one right). conf_api.c provides an API to build other
configuration file readers around (can you see a configuraion file in
XML? I can :-)).
Finally, I've changed the name conf_lcl.h to conf_def.h, since it's
made specifically for that "class" and none others.
2000-04-09 20:04:35 +08:00
|
|
|
end = eat_alpha_numeric(conf, s);
|
1998-12-21 18:52:47 +08:00
|
|
|
if ((end[0] == ':') && (end[1] == ':')) {
|
|
|
|
*end = '\0';
|
|
|
|
end += 2;
|
|
|
|
psection = pname;
|
|
|
|
pname = end;
|
I've always wanted to make the CONF library more adaptable. Here's
the result.
I have retained the old behavior of the CONF_* functions, and have
added a more "object oriented" interface through NCONF_* functions
(New CONF, you see :-)), working the same way as, for example, the
BIO interface. Really, the CONF_* are rewritten so they use the
NCONF_* functions internally.
In addition to that, I've split the old conf.c code into two files,
conf_def.c and conf_api.c. conf_def.c contains the default config
object that reads a configuration file the standard OpenSSL way, as
well as configuration file with Win32 registry file syntax (I'm not
sure I got that one right). conf_api.c provides an API to build other
configuration file readers around (can you see a configuraion file in
XML? I can :-)).
Finally, I've changed the name conf_lcl.h to conf_def.h, since it's
made specifically for that "class" and none others.
2000-04-09 20:04:35 +08:00
|
|
|
end = eat_alpha_numeric(conf, end);
|
2018-02-27 20:55:35 +08:00
|
|
|
} else {
|
|
|
|
psection = section;
|
1998-12-21 18:52:47 +08:00
|
|
|
}
|
I've always wanted to make the CONF library more adaptable. Here's
the result.
I have retained the old behavior of the CONF_* functions, and have
added a more "object oriented" interface through NCONF_* functions
(New CONF, you see :-)), working the same way as, for example, the
BIO interface. Really, the CONF_* are rewritten so they use the
NCONF_* functions internally.
In addition to that, I've split the old conf.c code into two files,
conf_def.c and conf_api.c. conf_def.c contains the default config
object that reads a configuration file the standard OpenSSL way, as
well as configuration file with Win32 registry file syntax (I'm not
sure I got that one right). conf_api.c provides an API to build other
configuration file readers around (can you see a configuraion file in
XML? I can :-)).
Finally, I've changed the name conf_lcl.h to conf_def.h, since it's
made specifically for that "class" and none others.
2000-04-09 20:04:35 +08:00
|
|
|
p = eat_ws(conf, end);
|
2021-06-21 14:55:50 +08:00
|
|
|
if (CHECK_AND_SKIP_PREFIX(pname, ".pragma")
|
|
|
|
&& (p != pname || *p == '=')) {
|
2019-05-06 16:50:35 +08:00
|
|
|
char *pval;
|
|
|
|
|
|
|
|
if (*p == '=') {
|
|
|
|
p++;
|
|
|
|
p = eat_ws(conf, p);
|
|
|
|
}
|
|
|
|
trim_ws(conf, p);
|
|
|
|
|
|
|
|
/* Pragma values take the form keyword:value */
|
|
|
|
pval = strchr(p, ':');
|
|
|
|
if (pval == NULL || pval == p || pval[1] == '\0') {
|
2020-11-04 19:23:19 +08:00
|
|
|
ERR_raise(ERR_LIB_CONF, CONF_R_INVALID_PRAGMA);
|
2019-05-06 16:50:35 +08:00
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
|
|
|
|
*pval++ = '\0';
|
|
|
|
trim_ws(conf, p);
|
|
|
|
pval = eat_ws(conf, pval);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Known pragmas:
|
|
|
|
*
|
|
|
|
* dollarid takes "on", "true or "off", "false"
|
2021-05-01 00:18:00 +08:00
|
|
|
* abspath takes "on", "true or "off", "false"
|
|
|
|
* includedir directory prefix
|
2019-05-06 16:50:35 +08:00
|
|
|
*/
|
|
|
|
if (strcmp(p, "dollarid") == 0) {
|
2021-04-30 04:22:30 +08:00
|
|
|
if (!parsebool(pval, &conf->flag_dollarid))
|
|
|
|
goto err;
|
|
|
|
} else if (strcmp(p, "abspath") == 0) {
|
|
|
|
if (!parsebool(pval, &conf->flag_abspath))
|
2019-05-06 16:50:35 +08:00
|
|
|
goto err;
|
2021-05-01 00:18:00 +08:00
|
|
|
} else if (strcmp(p, "includedir") == 0) {
|
2021-10-13 12:37:46 +08:00
|
|
|
OPENSSL_free(conf->includedir);
|
2022-09-29 19:57:34 +08:00
|
|
|
if ((conf->includedir = OPENSSL_strdup(pval)) == NULL)
|
2021-05-01 00:18:00 +08:00
|
|
|
goto err;
|
2019-05-06 16:50:35 +08:00
|
|
|
}
|
2021-05-01 00:18:00 +08:00
|
|
|
|
2019-05-06 16:50:35 +08:00
|
|
|
/*
|
|
|
|
* We *ignore* any unknown pragma.
|
|
|
|
*/
|
|
|
|
continue;
|
2021-06-21 14:55:50 +08:00
|
|
|
} else if (CHECK_AND_SKIP_PREFIX(pname, ".include")
|
|
|
|
&& (p != pname || *p == '=')) {
|
2018-02-27 20:55:35 +08:00
|
|
|
char *include = NULL;
|
|
|
|
BIO *next;
|
2019-09-15 17:55:10 +08:00
|
|
|
const char *include_dir = ossl_safe_getenv("OPENSSL_CONF_INCLUDE");
|
|
|
|
char *include_path = NULL;
|
2018-02-27 20:55:35 +08:00
|
|
|
|
2023-04-26 22:04:42 +08:00
|
|
|
#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
|
|
|
|
/*
|
|
|
|
* The include processing below can cause the "conf" fuzzer to
|
|
|
|
* timeout due to the fuzzer inserting large and complicated
|
|
|
|
* includes - with a large amount of time spent in
|
|
|
|
* OPENSSL_strlcat/OPENSSL_strcpy. This is not a security
|
|
|
|
* concern because config files should never come from untrusted
|
|
|
|
* sources. We just set an arbitrary limit on the allowed
|
|
|
|
* number of includes when fuzzing to prevent this timeout.
|
|
|
|
*/
|
|
|
|
if (numincludes++ > 10)
|
|
|
|
goto err;
|
|
|
|
#endif
|
|
|
|
|
2021-05-01 00:18:00 +08:00
|
|
|
if (include_dir == NULL)
|
|
|
|
include_dir = conf->includedir;
|
|
|
|
|
2019-02-01 21:32:36 +08:00
|
|
|
if (*p == '=') {
|
|
|
|
p++;
|
|
|
|
p = eat_ws(conf, p);
|
|
|
|
}
|
2018-02-27 20:55:35 +08:00
|
|
|
trim_ws(conf, p);
|
|
|
|
if (!str_copy(conf, psection, &include, p))
|
|
|
|
goto err;
|
2019-09-15 17:55:10 +08:00
|
|
|
|
2020-11-04 01:51:38 +08:00
|
|
|
if (include_dir != NULL && !ossl_is_absolute_path(include)) {
|
2019-09-15 17:55:10 +08:00
|
|
|
size_t newlen = strlen(include_dir) + strlen(include) + 2;
|
|
|
|
|
|
|
|
include_path = OPENSSL_malloc(newlen);
|
2020-11-04 01:51:38 +08:00
|
|
|
if (include_path == NULL) {
|
|
|
|
OPENSSL_free(include);
|
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
|
2019-09-15 17:55:10 +08:00
|
|
|
OPENSSL_strlcpy(include_path, include_dir, newlen);
|
2020-11-04 01:51:38 +08:00
|
|
|
if (!ossl_ends_with_dirsep(include_path))
|
|
|
|
OPENSSL_strlcat(include_path, "/", newlen);
|
2019-09-15 17:55:10 +08:00
|
|
|
OPENSSL_strlcat(include_path, include, newlen);
|
2020-05-01 22:15:13 +08:00
|
|
|
OPENSSL_free(include);
|
2019-09-15 17:55:10 +08:00
|
|
|
} else {
|
|
|
|
include_path = include;
|
|
|
|
}
|
|
|
|
|
2021-05-01 00:18:00 +08:00
|
|
|
if (conf->flag_abspath
|
|
|
|
&& !ossl_is_absolute_path(include_path)) {
|
|
|
|
ERR_raise(ERR_LIB_CONF, CONF_R_RELATIVE_PATH);
|
2021-10-13 01:38:14 +08:00
|
|
|
OPENSSL_free(include_path);
|
2021-05-01 00:18:00 +08:00
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
|
2018-02-27 20:55:35 +08:00
|
|
|
/* get the BIO of the included file */
|
|
|
|
#ifndef OPENSSL_NO_POSIX_IO
|
2019-09-15 17:55:10 +08:00
|
|
|
next = process_include(include_path, &dirctx, &dirpath);
|
|
|
|
if (include_path != dirpath) {
|
2018-02-27 20:55:35 +08:00
|
|
|
/* dirpath will contain include in case of a directory */
|
2020-05-01 22:15:13 +08:00
|
|
|
OPENSSL_free(include_path);
|
2018-02-27 20:55:35 +08:00
|
|
|
}
|
|
|
|
#else
|
2019-09-15 17:55:10 +08:00
|
|
|
next = BIO_new_file(include_path, "r");
|
2020-05-01 22:15:13 +08:00
|
|
|
OPENSSL_free(include_path);
|
2018-02-27 20:55:35 +08:00
|
|
|
#endif
|
2019-09-15 17:55:10 +08:00
|
|
|
|
2018-02-27 20:55:35 +08:00
|
|
|
if (next != NULL) {
|
|
|
|
/* push the currently processing BIO onto stack */
|
|
|
|
if (biosk == NULL) {
|
|
|
|
if ((biosk = sk_BIO_new_null()) == NULL) {
|
2022-09-29 19:57:34 +08:00
|
|
|
ERR_raise(ERR_LIB_CONF, ERR_R_CRYPTO_LIB);
|
2020-09-07 16:06:45 +08:00
|
|
|
BIO_free(next);
|
2018-02-27 20:55:35 +08:00
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!sk_BIO_push(biosk, in)) {
|
2022-09-29 19:57:34 +08:00
|
|
|
ERR_raise(ERR_LIB_CONF, ERR_R_CRYPTO_LIB);
|
2020-09-07 16:06:45 +08:00
|
|
|
BIO_free(next);
|
2018-02-27 20:55:35 +08:00
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
/* continue with reading from the included BIO */
|
|
|
|
in = next;
|
|
|
|
}
|
|
|
|
continue;
|
|
|
|
} else if (*p != '=') {
|
2020-11-04 23:14:00 +08:00
|
|
|
ERR_raise_data(ERR_LIB_CONF, CONF_R_MISSING_EQUAL_SIGN,
|
|
|
|
"HERE-->%s", p);
|
1998-12-21 18:52:47 +08:00
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
*end = '\0';
|
|
|
|
p++;
|
I've always wanted to make the CONF library more adaptable. Here's
the result.
I have retained the old behavior of the CONF_* functions, and have
added a more "object oriented" interface through NCONF_* functions
(New CONF, you see :-)), working the same way as, for example, the
BIO interface. Really, the CONF_* are rewritten so they use the
NCONF_* functions internally.
In addition to that, I've split the old conf.c code into two files,
conf_def.c and conf_api.c. conf_def.c contains the default config
object that reads a configuration file the standard OpenSSL way, as
well as configuration file with Win32 registry file syntax (I'm not
sure I got that one right). conf_api.c provides an API to build other
configuration file readers around (can you see a configuraion file in
XML? I can :-)).
Finally, I've changed the name conf_lcl.h to conf_def.h, since it's
made specifically for that "class" and none others.
2000-04-09 20:04:35 +08:00
|
|
|
start = eat_ws(conf, p);
|
2018-02-27 20:55:35 +08:00
|
|
|
trim_ws(conf, start);
|
2015-01-22 11:40:55 +08:00
|
|
|
|
2022-09-29 19:57:34 +08:00
|
|
|
if ((v = OPENSSL_malloc(sizeof(*v))) == NULL)
|
1998-12-21 18:52:47 +08:00
|
|
|
goto err;
|
2017-07-06 12:56:20 +08:00
|
|
|
v->name = OPENSSL_strdup(pname);
|
1998-12-21 18:52:47 +08:00
|
|
|
v->value = NULL;
|
2022-09-29 19:57:34 +08:00
|
|
|
if (v->name == NULL)
|
1998-12-21 18:52:47 +08:00
|
|
|
goto err;
|
I've always wanted to make the CONF library more adaptable. Here's
the result.
I have retained the old behavior of the CONF_* functions, and have
added a more "object oriented" interface through NCONF_* functions
(New CONF, you see :-)), working the same way as, for example, the
BIO interface. Really, the CONF_* are rewritten so they use the
NCONF_* functions internally.
In addition to that, I've split the old conf.c code into two files,
conf_def.c and conf_api.c. conf_def.c contains the default config
object that reads a configuration file the standard OpenSSL way, as
well as configuration file with Win32 registry file syntax (I'm not
sure I got that one right). conf_api.c provides an API to build other
configuration file readers around (can you see a configuraion file in
XML? I can :-)).
Finally, I've changed the name conf_lcl.h to conf_def.h, since it's
made specifically for that "class" and none others.
2000-04-09 20:04:35 +08:00
|
|
|
if (!str_copy(conf, psection, &(v->value), start))
|
|
|
|
goto err;
|
2015-01-22 11:40:55 +08:00
|
|
|
|
1998-12-21 18:52:47 +08:00
|
|
|
if (strcmp(psection, section) != 0) {
|
I've always wanted to make the CONF library more adaptable. Here's
the result.
I have retained the old behavior of the CONF_* functions, and have
added a more "object oriented" interface through NCONF_* functions
(New CONF, you see :-)), working the same way as, for example, the
BIO interface. Really, the CONF_* are rewritten so they use the
NCONF_* functions internally.
In addition to that, I've split the old conf.c code into two files,
conf_def.c and conf_api.c. conf_def.c contains the default config
object that reads a configuration file the standard OpenSSL way, as
well as configuration file with Win32 registry file syntax (I'm not
sure I got that one right). conf_api.c provides an API to build other
configuration file readers around (can you see a configuraion file in
XML? I can :-)).
Finally, I've changed the name conf_lcl.h to conf_def.h, since it's
made specifically for that "class" and none others.
2000-04-09 20:04:35 +08:00
|
|
|
if ((tv = _CONF_get_section(conf, psection))
|
1998-12-21 18:52:47 +08:00
|
|
|
== NULL)
|
I've always wanted to make the CONF library more adaptable. Here's
the result.
I have retained the old behavior of the CONF_* functions, and have
added a more "object oriented" interface through NCONF_* functions
(New CONF, you see :-)), working the same way as, for example, the
BIO interface. Really, the CONF_* are rewritten so they use the
NCONF_* functions internally.
In addition to that, I've split the old conf.c code into two files,
conf_def.c and conf_api.c. conf_def.c contains the default config
object that reads a configuration file the standard OpenSSL way, as
well as configuration file with Win32 registry file syntax (I'm not
sure I got that one right). conf_api.c provides an API to build other
configuration file readers around (can you see a configuraion file in
XML? I can :-)).
Finally, I've changed the name conf_lcl.h to conf_def.h, since it's
made specifically for that "class" and none others.
2000-04-09 20:04:35 +08:00
|
|
|
tv = _CONF_new_section(conf, psection);
|
1998-12-21 18:52:47 +08:00
|
|
|
if (tv == NULL) {
|
2020-11-04 19:23:19 +08:00
|
|
|
ERR_raise(ERR_LIB_CONF,
|
|
|
|
CONF_R_UNABLE_TO_CREATE_NEW_SECTION);
|
1998-12-21 18:52:47 +08:00
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
} else
|
|
|
|
tv = sv;
|
I've always wanted to make the CONF library more adaptable. Here's
the result.
I have retained the old behavior of the CONF_* functions, and have
added a more "object oriented" interface through NCONF_* functions
(New CONF, you see :-)), working the same way as, for example, the
BIO interface. Really, the CONF_* are rewritten so they use the
NCONF_* functions internally.
In addition to that, I've split the old conf.c code into two files,
conf_def.c and conf_api.c. conf_def.c contains the default config
object that reads a configuration file the standard OpenSSL way, as
well as configuration file with Win32 registry file syntax (I'm not
sure I got that one right). conf_api.c provides an API to build other
configuration file readers around (can you see a configuraion file in
XML? I can :-)).
Finally, I've changed the name conf_lcl.h to conf_def.h, since it's
made specifically for that "class" and none others.
2000-04-09 20:04:35 +08:00
|
|
|
if (_CONF_add_string(conf, tv, v) == 0) {
|
2022-09-29 19:57:34 +08:00
|
|
|
ERR_raise(ERR_LIB_CONF, ERR_R_CONF_LIB);
|
I've always wanted to make the CONF library more adaptable. Here's
the result.
I have retained the old behavior of the CONF_* functions, and have
added a more "object oriented" interface through NCONF_* functions
(New CONF, you see :-)), working the same way as, for example, the
BIO interface. Really, the CONF_* are rewritten so they use the
NCONF_* functions internally.
In addition to that, I've split the old conf.c code into two files,
conf_def.c and conf_api.c. conf_def.c contains the default config
object that reads a configuration file the standard OpenSSL way, as
well as configuration file with Win32 registry file syntax (I'm not
sure I got that one right). conf_api.c provides an API to build other
configuration file readers around (can you see a configuraion file in
XML? I can :-)).
Finally, I've changed the name conf_lcl.h to conf_def.h, since it's
made specifically for that "class" and none others.
2000-04-09 20:04:35 +08:00
|
|
|
goto err;
|
|
|
|
}
|
1998-12-21 18:52:47 +08:00
|
|
|
v = NULL;
|
|
|
|
}
|
|
|
|
}
|
2015-05-02 02:37:16 +08:00
|
|
|
BUF_MEM_free(buff);
|
2015-05-01 22:02:07 +08:00
|
|
|
OPENSSL_free(section);
|
2018-07-24 04:29:22 +08:00
|
|
|
/*
|
|
|
|
* No need to pop, since we only get here if the stack is empty.
|
|
|
|
* If this causes a BIO leak, THE ISSUE IS SOMEWHERE ELSE!
|
|
|
|
*/
|
|
|
|
sk_BIO_free(biosk);
|
2017-07-06 12:56:20 +08:00
|
|
|
return 1;
|
2021-05-01 00:18:00 +08:00
|
|
|
|
1998-12-21 18:52:47 +08:00
|
|
|
err:
|
2015-05-02 02:37:16 +08:00
|
|
|
BUF_MEM_free(buff);
|
2015-05-01 22:02:07 +08:00
|
|
|
OPENSSL_free(section);
|
2018-07-24 04:29:22 +08:00
|
|
|
/*
|
|
|
|
* Since |in| is the first element of the stack and should NOT be freed
|
|
|
|
* here, we cannot use sk_BIO_pop_free(). Instead, we pop and free one
|
|
|
|
* BIO at a time, making sure that the last one popped isn't.
|
|
|
|
*/
|
|
|
|
while (sk_BIO_num(biosk) > 0) {
|
|
|
|
BIO *popped = sk_BIO_pop(biosk);
|
|
|
|
BIO_vfree(in);
|
|
|
|
in = popped;
|
|
|
|
}
|
|
|
|
sk_BIO_free(biosk);
|
2018-02-27 20:55:35 +08:00
|
|
|
#ifndef OPENSSL_NO_POSIX_IO
|
|
|
|
OPENSSL_free(dirpath);
|
|
|
|
if (dirctx != NULL)
|
|
|
|
OPENSSL_DIR_end(&dirctx);
|
|
|
|
#endif
|
1998-12-21 18:52:47 +08:00
|
|
|
if (line != NULL)
|
|
|
|
*line = eline;
|
2017-07-06 12:56:20 +08:00
|
|
|
BIO_snprintf(btmp, sizeof(btmp), "%ld", eline);
|
1998-12-21 19:00:56 +08:00
|
|
|
ERR_add_error_data(2, "line ", btmp);
|
2015-05-02 02:37:16 +08:00
|
|
|
if (h != conf->data) {
|
2002-01-18 19:32:30 +08:00
|
|
|
CONF_free(conf->data);
|
|
|
|
conf->data = NULL;
|
|
|
|
}
|
1998-12-21 18:52:47 +08:00
|
|
|
if (v != NULL) {
|
2015-05-01 22:02:07 +08:00
|
|
|
OPENSSL_free(v->name);
|
|
|
|
OPENSSL_free(v->value);
|
|
|
|
OPENSSL_free(v);
|
1998-12-21 18:52:47 +08:00
|
|
|
}
|
2017-07-06 12:56:20 +08:00
|
|
|
return 0;
|
1998-12-21 18:52:47 +08:00
|
|
|
}
|
1999-06-21 01:36:11 +08:00
|
|
|
|
I've always wanted to make the CONF library more adaptable. Here's
the result.
I have retained the old behavior of the CONF_* functions, and have
added a more "object oriented" interface through NCONF_* functions
(New CONF, you see :-)), working the same way as, for example, the
BIO interface. Really, the CONF_* are rewritten so they use the
NCONF_* functions internally.
In addition to that, I've split the old conf.c code into two files,
conf_def.c and conf_api.c. conf_def.c contains the default config
object that reads a configuration file the standard OpenSSL way, as
well as configuration file with Win32 registry file syntax (I'm not
sure I got that one right). conf_api.c provides an API to build other
configuration file readers around (can you see a configuraion file in
XML? I can :-)).
Finally, I've changed the name conf_lcl.h to conf_def.h, since it's
made specifically for that "class" and none others.
2000-04-09 20:04:35 +08:00
|
|
|
static void clear_comments(CONF *conf, char *p)
|
1998-12-21 18:52:47 +08:00
|
|
|
{
|
I've always wanted to make the CONF library more adaptable. Here's
the result.
I have retained the old behavior of the CONF_* functions, and have
added a more "object oriented" interface through NCONF_* functions
(New CONF, you see :-)), working the same way as, for example, the
BIO interface. Really, the CONF_* are rewritten so they use the
NCONF_* functions internally.
In addition to that, I've split the old conf.c code into two files,
conf_def.c and conf_api.c. conf_def.c contains the default config
object that reads a configuration file the standard OpenSSL way, as
well as configuration file with Win32 registry file syntax (I'm not
sure I got that one right). conf_api.c provides an API to build other
configuration file readers around (can you see a configuraion file in
XML? I can :-)).
Finally, I've changed the name conf_lcl.h to conf_def.h, since it's
made specifically for that "class" and none others.
2000-04-09 20:04:35 +08:00
|
|
|
for (;;) {
|
|
|
|
if (IS_FCOMMENT(conf, *p)) {
|
|
|
|
*p = '\0';
|
|
|
|
return;
|
1998-12-21 18:52:47 +08:00
|
|
|
}
|
I've always wanted to make the CONF library more adaptable. Here's
the result.
I have retained the old behavior of the CONF_* functions, and have
added a more "object oriented" interface through NCONF_* functions
(New CONF, you see :-)), working the same way as, for example, the
BIO interface. Really, the CONF_* are rewritten so they use the
NCONF_* functions internally.
In addition to that, I've split the old conf.c code into two files,
conf_def.c and conf_api.c. conf_def.c contains the default config
object that reads a configuration file the standard OpenSSL way, as
well as configuration file with Win32 registry file syntax (I'm not
sure I got that one right). conf_api.c provides an API to build other
configuration file readers around (can you see a configuraion file in
XML? I can :-)).
Finally, I've changed the name conf_lcl.h to conf_def.h, since it's
made specifically for that "class" and none others.
2000-04-09 20:04:35 +08:00
|
|
|
if (!IS_WS(conf, *p)) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
p++;
|
1998-12-21 18:52:47 +08:00
|
|
|
}
|
2015-01-22 11:40:55 +08:00
|
|
|
|
1998-12-21 18:52:47 +08:00
|
|
|
for (;;) {
|
I've always wanted to make the CONF library more adaptable. Here's
the result.
I have retained the old behavior of the CONF_* functions, and have
added a more "object oriented" interface through NCONF_* functions
(New CONF, you see :-)), working the same way as, for example, the
BIO interface. Really, the CONF_* are rewritten so they use the
NCONF_* functions internally.
In addition to that, I've split the old conf.c code into two files,
conf_def.c and conf_api.c. conf_def.c contains the default config
object that reads a configuration file the standard OpenSSL way, as
well as configuration file with Win32 registry file syntax (I'm not
sure I got that one right). conf_api.c provides an API to build other
configuration file readers around (can you see a configuraion file in
XML? I can :-)).
Finally, I've changed the name conf_lcl.h to conf_def.h, since it's
made specifically for that "class" and none others.
2000-04-09 20:04:35 +08:00
|
|
|
if (IS_COMMENT(conf, *p)) {
|
1998-12-21 18:52:47 +08:00
|
|
|
*p = '\0';
|
|
|
|
return;
|
|
|
|
}
|
I've always wanted to make the CONF library more adaptable. Here's
the result.
I have retained the old behavior of the CONF_* functions, and have
added a more "object oriented" interface through NCONF_* functions
(New CONF, you see :-)), working the same way as, for example, the
BIO interface. Really, the CONF_* are rewritten so they use the
NCONF_* functions internally.
In addition to that, I've split the old conf.c code into two files,
conf_def.c and conf_api.c. conf_def.c contains the default config
object that reads a configuration file the standard OpenSSL way, as
well as configuration file with Win32 registry file syntax (I'm not
sure I got that one right). conf_api.c provides an API to build other
configuration file readers around (can you see a configuraion file in
XML? I can :-)).
Finally, I've changed the name conf_lcl.h to conf_def.h, since it's
made specifically for that "class" and none others.
2000-04-09 20:04:35 +08:00
|
|
|
if (IS_DQUOTE(conf, *p)) {
|
|
|
|
p = scan_dquote(conf, p);
|
1998-12-21 18:52:47 +08:00
|
|
|
continue;
|
|
|
|
}
|
I've always wanted to make the CONF library more adaptable. Here's
the result.
I have retained the old behavior of the CONF_* functions, and have
added a more "object oriented" interface through NCONF_* functions
(New CONF, you see :-)), working the same way as, for example, the
BIO interface. Really, the CONF_* are rewritten so they use the
NCONF_* functions internally.
In addition to that, I've split the old conf.c code into two files,
conf_def.c and conf_api.c. conf_def.c contains the default config
object that reads a configuration file the standard OpenSSL way, as
well as configuration file with Win32 registry file syntax (I'm not
sure I got that one right). conf_api.c provides an API to build other
configuration file readers around (can you see a configuraion file in
XML? I can :-)).
Finally, I've changed the name conf_lcl.h to conf_def.h, since it's
made specifically for that "class" and none others.
2000-04-09 20:04:35 +08:00
|
|
|
if (IS_QUOTE(conf, *p)) {
|
|
|
|
p = scan_quote(conf, p);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (IS_ESC(conf, *p)) {
|
2000-06-06 23:21:12 +08:00
|
|
|
p = scan_esc(conf, p);
|
1998-12-21 18:52:47 +08:00
|
|
|
continue;
|
|
|
|
}
|
I've always wanted to make the CONF library more adaptable. Here's
the result.
I have retained the old behavior of the CONF_* functions, and have
added a more "object oriented" interface through NCONF_* functions
(New CONF, you see :-)), working the same way as, for example, the
BIO interface. Really, the CONF_* are rewritten so they use the
NCONF_* functions internally.
In addition to that, I've split the old conf.c code into two files,
conf_def.c and conf_api.c. conf_def.c contains the default config
object that reads a configuration file the standard OpenSSL way, as
well as configuration file with Win32 registry file syntax (I'm not
sure I got that one right). conf_api.c provides an API to build other
configuration file readers around (can you see a configuraion file in
XML? I can :-)).
Finally, I've changed the name conf_lcl.h to conf_def.h, since it's
made specifically for that "class" and none others.
2000-04-09 20:04:35 +08:00
|
|
|
if (IS_EOF(conf, *p))
|
1998-12-21 18:52:47 +08:00
|
|
|
return;
|
|
|
|
else
|
|
|
|
p++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
I've always wanted to make the CONF library more adaptable. Here's
the result.
I have retained the old behavior of the CONF_* functions, and have
added a more "object oriented" interface through NCONF_* functions
(New CONF, you see :-)), working the same way as, for example, the
BIO interface. Really, the CONF_* are rewritten so they use the
NCONF_* functions internally.
In addition to that, I've split the old conf.c code into two files,
conf_def.c and conf_api.c. conf_def.c contains the default config
object that reads a configuration file the standard OpenSSL way, as
well as configuration file with Win32 registry file syntax (I'm not
sure I got that one right). conf_api.c provides an API to build other
configuration file readers around (can you see a configuraion file in
XML? I can :-)).
Finally, I've changed the name conf_lcl.h to conf_def.h, since it's
made specifically for that "class" and none others.
2000-04-09 20:04:35 +08:00
|
|
|
static int str_copy(CONF *conf, char *section, char **pto, char *from)
|
1998-12-21 18:52:47 +08:00
|
|
|
{
|
|
|
|
int q, r, rr = 0, to = 0, len = 0;
|
|
|
|
char *s, *e, *rp, *p, *rrp, *np, *cp, v;
|
|
|
|
BUF_MEM *buf;
|
2015-01-22 11:40:55 +08:00
|
|
|
|
1998-12-21 18:52:47 +08:00
|
|
|
if ((buf = BUF_MEM_new()) == NULL)
|
2017-07-06 12:56:20 +08:00
|
|
|
return 0;
|
2015-01-22 11:40:55 +08:00
|
|
|
|
1998-12-21 18:52:47 +08:00
|
|
|
len = strlen(from) + 1;
|
|
|
|
if (!BUF_MEM_grow(buf, len))
|
|
|
|
goto err;
|
2015-01-22 11:40:55 +08:00
|
|
|
|
1998-12-21 18:52:47 +08:00
|
|
|
for (;;) {
|
I've always wanted to make the CONF library more adaptable. Here's
the result.
I have retained the old behavior of the CONF_* functions, and have
added a more "object oriented" interface through NCONF_* functions
(New CONF, you see :-)), working the same way as, for example, the
BIO interface. Really, the CONF_* are rewritten so they use the
NCONF_* functions internally.
In addition to that, I've split the old conf.c code into two files,
conf_def.c and conf_api.c. conf_def.c contains the default config
object that reads a configuration file the standard OpenSSL way, as
well as configuration file with Win32 registry file syntax (I'm not
sure I got that one right). conf_api.c provides an API to build other
configuration file readers around (can you see a configuraion file in
XML? I can :-)).
Finally, I've changed the name conf_lcl.h to conf_def.h, since it's
made specifically for that "class" and none others.
2000-04-09 20:04:35 +08:00
|
|
|
if (IS_QUOTE(conf, *from)) {
|
1998-12-21 18:52:47 +08:00
|
|
|
q = *from;
|
|
|
|
from++;
|
I've always wanted to make the CONF library more adaptable. Here's
the result.
I have retained the old behavior of the CONF_* functions, and have
added a more "object oriented" interface through NCONF_* functions
(New CONF, you see :-)), working the same way as, for example, the
BIO interface. Really, the CONF_* are rewritten so they use the
NCONF_* functions internally.
In addition to that, I've split the old conf.c code into two files,
conf_def.c and conf_api.c. conf_def.c contains the default config
object that reads a configuration file the standard OpenSSL way, as
well as configuration file with Win32 registry file syntax (I'm not
sure I got that one right). conf_api.c provides an API to build other
configuration file readers around (can you see a configuraion file in
XML? I can :-)).
Finally, I've changed the name conf_lcl.h to conf_def.h, since it's
made specifically for that "class" and none others.
2000-04-09 20:04:35 +08:00
|
|
|
while (!IS_EOF(conf, *from) && (*from != q)) {
|
|
|
|
if (IS_ESC(conf, *from)) {
|
1998-12-21 18:52:47 +08:00
|
|
|
from++;
|
I've always wanted to make the CONF library more adaptable. Here's
the result.
I have retained the old behavior of the CONF_* functions, and have
added a more "object oriented" interface through NCONF_* functions
(New CONF, you see :-)), working the same way as, for example, the
BIO interface. Really, the CONF_* are rewritten so they use the
NCONF_* functions internally.
In addition to that, I've split the old conf.c code into two files,
conf_def.c and conf_api.c. conf_def.c contains the default config
object that reads a configuration file the standard OpenSSL way, as
well as configuration file with Win32 registry file syntax (I'm not
sure I got that one right). conf_api.c provides an API to build other
configuration file readers around (can you see a configuraion file in
XML? I can :-)).
Finally, I've changed the name conf_lcl.h to conf_def.h, since it's
made specifically for that "class" and none others.
2000-04-09 20:04:35 +08:00
|
|
|
if (IS_EOF(conf, *from))
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
buf->data[to++] = *(from++);
|
|
|
|
}
|
|
|
|
if (*from == q)
|
|
|
|
from++;
|
|
|
|
} else if (IS_DQUOTE(conf, *from)) {
|
|
|
|
q = *from;
|
|
|
|
from++;
|
|
|
|
while (!IS_EOF(conf, *from)) {
|
|
|
|
if (*from == q) {
|
|
|
|
if (*(from + 1) == q) {
|
|
|
|
from++;
|
|
|
|
} else {
|
|
|
|
break;
|
2015-01-22 11:40:55 +08:00
|
|
|
}
|
I've always wanted to make the CONF library more adaptable. Here's
the result.
I have retained the old behavior of the CONF_* functions, and have
added a more "object oriented" interface through NCONF_* functions
(New CONF, you see :-)), working the same way as, for example, the
BIO interface. Really, the CONF_* are rewritten so they use the
NCONF_* functions internally.
In addition to that, I've split the old conf.c code into two files,
conf_def.c and conf_api.c. conf_def.c contains the default config
object that reads a configuration file the standard OpenSSL way, as
well as configuration file with Win32 registry file syntax (I'm not
sure I got that one right). conf_api.c provides an API to build other
configuration file readers around (can you see a configuraion file in
XML? I can :-)).
Finally, I've changed the name conf_lcl.h to conf_def.h, since it's
made specifically for that "class" and none others.
2000-04-09 20:04:35 +08:00
|
|
|
}
|
1998-12-21 18:52:47 +08:00
|
|
|
buf->data[to++] = *(from++);
|
|
|
|
}
|
I've always wanted to make the CONF library more adaptable. Here's
the result.
I have retained the old behavior of the CONF_* functions, and have
added a more "object oriented" interface through NCONF_* functions
(New CONF, you see :-)), working the same way as, for example, the
BIO interface. Really, the CONF_* are rewritten so they use the
NCONF_* functions internally.
In addition to that, I've split the old conf.c code into two files,
conf_def.c and conf_api.c. conf_def.c contains the default config
object that reads a configuration file the standard OpenSSL way, as
well as configuration file with Win32 registry file syntax (I'm not
sure I got that one right). conf_api.c provides an API to build other
configuration file readers around (can you see a configuraion file in
XML? I can :-)).
Finally, I've changed the name conf_lcl.h to conf_def.h, since it's
made specifically for that "class" and none others.
2000-04-09 20:04:35 +08:00
|
|
|
if (*from == q)
|
|
|
|
from++;
|
|
|
|
} else if (IS_ESC(conf, *from)) {
|
1998-12-21 18:52:47 +08:00
|
|
|
from++;
|
|
|
|
v = *(from++);
|
I've always wanted to make the CONF library more adaptable. Here's
the result.
I have retained the old behavior of the CONF_* functions, and have
added a more "object oriented" interface through NCONF_* functions
(New CONF, you see :-)), working the same way as, for example, the
BIO interface. Really, the CONF_* are rewritten so they use the
NCONF_* functions internally.
In addition to that, I've split the old conf.c code into two files,
conf_def.c and conf_api.c. conf_def.c contains the default config
object that reads a configuration file the standard OpenSSL way, as
well as configuration file with Win32 registry file syntax (I'm not
sure I got that one right). conf_api.c provides an API to build other
configuration file readers around (can you see a configuraion file in
XML? I can :-)).
Finally, I've changed the name conf_lcl.h to conf_def.h, since it's
made specifically for that "class" and none others.
2000-04-09 20:04:35 +08:00
|
|
|
if (IS_EOF(conf, v))
|
|
|
|
break;
|
1998-12-21 18:52:47 +08:00
|
|
|
else if (v == 'r')
|
|
|
|
v = '\r';
|
|
|
|
else if (v == 'n')
|
|
|
|
v = '\n';
|
|
|
|
else if (v == 'b')
|
|
|
|
v = '\b';
|
|
|
|
else if (v == 't')
|
|
|
|
v = '\t';
|
|
|
|
buf->data[to++] = v;
|
I've always wanted to make the CONF library more adaptable. Here's
the result.
I have retained the old behavior of the CONF_* functions, and have
added a more "object oriented" interface through NCONF_* functions
(New CONF, you see :-)), working the same way as, for example, the
BIO interface. Really, the CONF_* are rewritten so they use the
NCONF_* functions internally.
In addition to that, I've split the old conf.c code into two files,
conf_def.c and conf_api.c. conf_def.c contains the default config
object that reads a configuration file the standard OpenSSL way, as
well as configuration file with Win32 registry file syntax (I'm not
sure I got that one right). conf_api.c provides an API to build other
configuration file readers around (can you see a configuraion file in
XML? I can :-)).
Finally, I've changed the name conf_lcl.h to conf_def.h, since it's
made specifically for that "class" and none others.
2000-04-09 20:04:35 +08:00
|
|
|
} else if (IS_EOF(conf, *from))
|
1998-12-21 18:52:47 +08:00
|
|
|
break;
|
2019-05-06 16:50:35 +08:00
|
|
|
else if (*from == '$'
|
|
|
|
&& (!conf->flag_dollarid
|
|
|
|
|| from[1] == '{'
|
|
|
|
|| from[1] == '(')) {
|
2017-03-10 18:51:35 +08:00
|
|
|
size_t newsize;
|
|
|
|
|
1998-12-21 18:52:47 +08:00
|
|
|
/* try to expand it */
|
|
|
|
rrp = NULL;
|
|
|
|
s = &(from[1]);
|
|
|
|
if (*s == '{')
|
|
|
|
q = '}';
|
|
|
|
else if (*s == '(')
|
|
|
|
q = ')';
|
|
|
|
else
|
|
|
|
q = 0;
|
2015-01-22 11:40:55 +08:00
|
|
|
|
1998-12-21 18:52:47 +08:00
|
|
|
if (q)
|
|
|
|
s++;
|
|
|
|
cp = section;
|
|
|
|
e = np = s;
|
2019-05-06 16:50:35 +08:00
|
|
|
while (IS_ALNUM(conf, *e)
|
|
|
|
|| (conf->flag_dollarid && IS_DOLLAR(conf, *e)))
|
1998-12-21 18:52:47 +08:00
|
|
|
e++;
|
|
|
|
if ((e[0] == ':') && (e[1] == ':')) {
|
|
|
|
cp = np;
|
|
|
|
rrp = e;
|
|
|
|
rr = *e;
|
|
|
|
*rrp = '\0';
|
|
|
|
e += 2;
|
|
|
|
np = e;
|
2019-05-06 16:50:35 +08:00
|
|
|
while (IS_ALNUM(conf, *e)
|
|
|
|
|| (conf->flag_dollarid && IS_DOLLAR(conf, *e)))
|
1998-12-21 18:52:47 +08:00
|
|
|
e++;
|
|
|
|
}
|
|
|
|
r = *e;
|
|
|
|
*e = '\0';
|
|
|
|
rp = e;
|
|
|
|
if (q) {
|
|
|
|
if (r != q) {
|
2020-11-04 19:23:19 +08:00
|
|
|
ERR_raise(ERR_LIB_CONF, CONF_R_NO_CLOSE_BRACE);
|
1998-12-21 18:52:47 +08:00
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
e++;
|
|
|
|
}
|
2015-01-05 19:30:03 +08:00
|
|
|
/*-
|
|
|
|
* So at this point we have
|
|
|
|
* np which is the start of the name string which is
|
|
|
|
* '\0' terminated.
|
|
|
|
* cp which is the start of the section string which is
|
|
|
|
* '\0' terminated.
|
|
|
|
* e is the 'next point after'.
|
|
|
|
* r and rr are the chars replaced by the '\0'
|
|
|
|
* rp and rrp is where 'r' and 'rr' came from.
|
|
|
|
*/
|
I've always wanted to make the CONF library more adaptable. Here's
the result.
I have retained the old behavior of the CONF_* functions, and have
added a more "object oriented" interface through NCONF_* functions
(New CONF, you see :-)), working the same way as, for example, the
BIO interface. Really, the CONF_* are rewritten so they use the
NCONF_* functions internally.
In addition to that, I've split the old conf.c code into two files,
conf_def.c and conf_api.c. conf_def.c contains the default config
object that reads a configuration file the standard OpenSSL way, as
well as configuration file with Win32 registry file syntax (I'm not
sure I got that one right). conf_api.c provides an API to build other
configuration file readers around (can you see a configuraion file in
XML? I can :-)).
Finally, I've changed the name conf_lcl.h to conf_def.h, since it's
made specifically for that "class" and none others.
2000-04-09 20:04:35 +08:00
|
|
|
p = _CONF_get_string(conf, cp, np);
|
1998-12-21 18:52:47 +08:00
|
|
|
if (rrp != NULL)
|
|
|
|
*rrp = rr;
|
|
|
|
*rp = r;
|
|
|
|
if (p == NULL) {
|
2020-11-04 19:23:19 +08:00
|
|
|
ERR_raise(ERR_LIB_CONF, CONF_R_VARIABLE_HAS_NO_VALUE);
|
1998-12-21 18:52:47 +08:00
|
|
|
goto err;
|
|
|
|
}
|
2017-03-10 18:51:35 +08:00
|
|
|
newsize = strlen(p) + buf->length - (e - from);
|
|
|
|
if (newsize > MAX_CONF_VALUE_LENGTH) {
|
2020-11-04 19:23:19 +08:00
|
|
|
ERR_raise(ERR_LIB_CONF, CONF_R_VARIABLE_EXPANSION_TOO_LONG);
|
2017-03-10 18:51:35 +08:00
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
if (!BUF_MEM_grow_clean(buf, newsize)) {
|
2022-09-29 19:57:34 +08:00
|
|
|
ERR_raise(ERR_LIB_CONF, ERR_R_BUF_LIB);
|
2015-02-13 02:00:42 +08:00
|
|
|
goto err;
|
|
|
|
}
|
1998-12-21 18:52:47 +08:00
|
|
|
while (*p)
|
|
|
|
buf->data[to++] = *(p++);
|
2015-01-22 11:40:55 +08:00
|
|
|
|
2004-05-06 17:33:22 +08:00
|
|
|
/*
|
|
|
|
* Since we change the pointer 'from', we also have to change the
|
|
|
|
* perceived length of the string it points at. /RL
|
|
|
|
*/
|
|
|
|
len -= e - from;
|
1998-12-21 18:52:47 +08:00
|
|
|
from = e;
|
2015-01-22 11:40:55 +08:00
|
|
|
|
2005-09-29 02:02:41 +08:00
|
|
|
/*
|
|
|
|
* In case there were no braces or parenthesis around the
|
|
|
|
* variable reference, we have to put back the character that was
|
|
|
|
* replaced with a '\0'. /RL
|
|
|
|
*/
|
|
|
|
*rp = r;
|
1998-12-21 18:52:47 +08:00
|
|
|
} else
|
|
|
|
buf->data[to++] = *(from++);
|
|
|
|
}
|
|
|
|
buf->data[to] = '\0';
|
2015-05-01 22:02:07 +08:00
|
|
|
OPENSSL_free(*pto);
|
1998-12-21 18:52:47 +08:00
|
|
|
*pto = buf->data;
|
2000-06-02 06:19:21 +08:00
|
|
|
OPENSSL_free(buf);
|
2017-07-06 12:56:20 +08:00
|
|
|
return 1;
|
1998-12-21 18:52:47 +08:00
|
|
|
err:
|
2015-05-02 02:37:16 +08:00
|
|
|
BUF_MEM_free(buf);
|
2017-07-06 12:56:20 +08:00
|
|
|
return 0;
|
1998-12-21 18:52:47 +08:00
|
|
|
}
|
|
|
|
|
2018-02-27 20:55:35 +08:00
|
|
|
#ifndef OPENSSL_NO_POSIX_IO
|
|
|
|
/*
|
|
|
|
* Check whether included path is a directory.
|
|
|
|
* Returns next BIO to process and in case of a directory
|
|
|
|
* also an opened directory context and the include path.
|
|
|
|
*/
|
|
|
|
static BIO *process_include(char *include, OPENSSL_DIR_CTX **dirctx,
|
|
|
|
char **dirpath)
|
|
|
|
{
|
2019-03-29 16:19:19 +08:00
|
|
|
struct stat st;
|
2018-02-27 20:55:35 +08:00
|
|
|
BIO *next;
|
|
|
|
|
|
|
|
if (stat(include, &st) < 0) {
|
2020-11-04 19:23:19 +08:00
|
|
|
ERR_raise_data(ERR_LIB_SYS, errno, "calling stat(%s)", include);
|
2018-02-27 20:55:35 +08:00
|
|
|
/* missing include file is not fatal error */
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2018-07-19 21:28:34 +08:00
|
|
|
if (S_ISDIR(st.st_mode)) {
|
2018-02-27 20:55:35 +08:00
|
|
|
if (*dirctx != NULL) {
|
2020-11-04 23:14:00 +08:00
|
|
|
ERR_raise_data(ERR_LIB_CONF, CONF_R_RECURSIVE_DIRECTORY_INCLUDE,
|
|
|
|
"%s", include);
|
2018-02-27 20:55:35 +08:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
/* a directory, load its contents */
|
|
|
|
if ((next = get_next_file(include, dirctx)) != NULL)
|
|
|
|
*dirpath = include;
|
|
|
|
return next;
|
|
|
|
}
|
|
|
|
|
|
|
|
next = BIO_new_file(include, "r");
|
|
|
|
return next;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Get next file from the directory path.
|
|
|
|
* Returns BIO of the next file to read and updates dirctx.
|
|
|
|
*/
|
|
|
|
static BIO *get_next_file(const char *path, OPENSSL_DIR_CTX **dirctx)
|
|
|
|
{
|
|
|
|
const char *filename;
|
2019-11-05 09:32:43 +08:00
|
|
|
size_t pathlen;
|
2018-02-27 20:55:35 +08:00
|
|
|
|
2019-11-05 09:32:43 +08:00
|
|
|
pathlen = strlen(path);
|
2018-02-27 20:55:35 +08:00
|
|
|
while ((filename = OPENSSL_DIR_read(dirctx, path)) != NULL) {
|
|
|
|
size_t namelen;
|
|
|
|
|
|
|
|
namelen = strlen(filename);
|
|
|
|
|
2018-03-11 17:14:11 +08:00
|
|
|
|
2022-04-12 18:30:08 +08:00
|
|
|
if ((namelen > 5
|
|
|
|
&& OPENSSL_strcasecmp(filename + namelen - 5, ".conf") == 0)
|
|
|
|
|| (namelen > 4
|
|
|
|
&& OPENSSL_strcasecmp(filename + namelen - 4, ".cnf") == 0)) {
|
2018-02-27 20:55:35 +08:00
|
|
|
size_t newlen;
|
|
|
|
char *newpath;
|
|
|
|
BIO *bio;
|
|
|
|
|
2019-11-05 09:32:43 +08:00
|
|
|
newlen = pathlen + namelen + 2;
|
2018-02-27 20:55:35 +08:00
|
|
|
newpath = OPENSSL_zalloc(newlen);
|
2022-09-29 19:57:34 +08:00
|
|
|
if (newpath == NULL)
|
2018-02-27 20:55:35 +08:00
|
|
|
break;
|
2018-03-11 17:14:11 +08:00
|
|
|
#ifdef OPENSSL_SYS_VMS
|
|
|
|
/*
|
|
|
|
* If the given path isn't clear VMS syntax,
|
|
|
|
* we treat it as on Unix.
|
|
|
|
*/
|
2019-11-05 09:32:43 +08:00
|
|
|
if (path[pathlen - 1] == ']'
|
|
|
|
|| path[pathlen - 1] == '>'
|
|
|
|
|| path[pathlen - 1] == ':') {
|
|
|
|
/* Clear VMS directory syntax, just copy as is */
|
|
|
|
OPENSSL_strlcpy(newpath, path, newlen);
|
2018-03-11 17:14:11 +08:00
|
|
|
}
|
2018-02-27 20:55:35 +08:00
|
|
|
#endif
|
2018-03-11 17:14:11 +08:00
|
|
|
if (newpath[0] == '\0') {
|
|
|
|
OPENSSL_strlcpy(newpath, path, newlen);
|
|
|
|
OPENSSL_strlcat(newpath, "/", newlen);
|
|
|
|
}
|
2018-02-27 20:55:35 +08:00
|
|
|
OPENSSL_strlcat(newpath, filename, newlen);
|
|
|
|
|
|
|
|
bio = BIO_new_file(newpath, "r");
|
|
|
|
OPENSSL_free(newpath);
|
|
|
|
/* Errors when opening files are non-fatal. */
|
|
|
|
if (bio != NULL)
|
|
|
|
return bio;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
OPENSSL_DIR_end(dirctx);
|
|
|
|
*dirctx = NULL;
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2018-04-03 04:37:30 +08:00
|
|
|
static int is_keytype(const CONF *conf, char c, unsigned short type)
|
|
|
|
{
|
2023-07-17 02:03:40 +08:00
|
|
|
const unsigned short *keytypes = (const unsigned short *) conf->meth_data;
|
2018-04-03 04:37:30 +08:00
|
|
|
unsigned char key = (unsigned char)c;
|
|
|
|
|
|
|
|
#ifdef CHARSET_EBCDIC
|
|
|
|
# if CHAR_BIT > 8
|
|
|
|
if (key > 255) {
|
|
|
|
/* key is out of range for os_toascii table */
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
# endif
|
|
|
|
/* convert key from ebcdic to ascii */
|
|
|
|
key = os_toascii[key];
|
|
|
|
#endif
|
|
|
|
|
|
|
|
if (key > 127) {
|
|
|
|
/* key is not a seven bit ascii character */
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
return (keytypes[key] & type) ? 1 : 0;
|
|
|
|
}
|
|
|
|
|
I've always wanted to make the CONF library more adaptable. Here's
the result.
I have retained the old behavior of the CONF_* functions, and have
added a more "object oriented" interface through NCONF_* functions
(New CONF, you see :-)), working the same way as, for example, the
BIO interface. Really, the CONF_* are rewritten so they use the
NCONF_* functions internally.
In addition to that, I've split the old conf.c code into two files,
conf_def.c and conf_api.c. conf_def.c contains the default config
object that reads a configuration file the standard OpenSSL way, as
well as configuration file with Win32 registry file syntax (I'm not
sure I got that one right). conf_api.c provides an API to build other
configuration file readers around (can you see a configuraion file in
XML? I can :-)).
Finally, I've changed the name conf_lcl.h to conf_def.h, since it's
made specifically for that "class" and none others.
2000-04-09 20:04:35 +08:00
|
|
|
static char *eat_ws(CONF *conf, char *p)
|
1998-12-21 18:52:47 +08:00
|
|
|
{
|
I've always wanted to make the CONF library more adaptable. Here's
the result.
I have retained the old behavior of the CONF_* functions, and have
added a more "object oriented" interface through NCONF_* functions
(New CONF, you see :-)), working the same way as, for example, the
BIO interface. Really, the CONF_* are rewritten so they use the
NCONF_* functions internally.
In addition to that, I've split the old conf.c code into two files,
conf_def.c and conf_api.c. conf_def.c contains the default config
object that reads a configuration file the standard OpenSSL way, as
well as configuration file with Win32 registry file syntax (I'm not
sure I got that one right). conf_api.c provides an API to build other
configuration file readers around (can you see a configuraion file in
XML? I can :-)).
Finally, I've changed the name conf_lcl.h to conf_def.h, since it's
made specifically for that "class" and none others.
2000-04-09 20:04:35 +08:00
|
|
|
while (IS_WS(conf, *p) && (!IS_EOF(conf, *p)))
|
1998-12-21 18:52:47 +08:00
|
|
|
p++;
|
2017-07-06 12:56:20 +08:00
|
|
|
return p;
|
1998-12-21 18:52:47 +08:00
|
|
|
}
|
|
|
|
|
2018-02-27 20:55:35 +08:00
|
|
|
static void trim_ws(CONF *conf, char *start)
|
|
|
|
{
|
|
|
|
char *p = start;
|
|
|
|
|
|
|
|
while (!IS_EOF(conf, *p))
|
|
|
|
p++;
|
|
|
|
p--;
|
|
|
|
while ((p >= start) && IS_WS(conf, *p))
|
|
|
|
p--;
|
|
|
|
p++;
|
|
|
|
*p = '\0';
|
|
|
|
}
|
|
|
|
|
I've always wanted to make the CONF library more adaptable. Here's
the result.
I have retained the old behavior of the CONF_* functions, and have
added a more "object oriented" interface through NCONF_* functions
(New CONF, you see :-)), working the same way as, for example, the
BIO interface. Really, the CONF_* are rewritten so they use the
NCONF_* functions internally.
In addition to that, I've split the old conf.c code into two files,
conf_def.c and conf_api.c. conf_def.c contains the default config
object that reads a configuration file the standard OpenSSL way, as
well as configuration file with Win32 registry file syntax (I'm not
sure I got that one right). conf_api.c provides an API to build other
configuration file readers around (can you see a configuraion file in
XML? I can :-)).
Finally, I've changed the name conf_lcl.h to conf_def.h, since it's
made specifically for that "class" and none others.
2000-04-09 20:04:35 +08:00
|
|
|
static char *eat_alpha_numeric(CONF *conf, char *p)
|
1998-12-21 18:52:47 +08:00
|
|
|
{
|
|
|
|
for (;;) {
|
I've always wanted to make the CONF library more adaptable. Here's
the result.
I have retained the old behavior of the CONF_* functions, and have
added a more "object oriented" interface through NCONF_* functions
(New CONF, you see :-)), working the same way as, for example, the
BIO interface. Really, the CONF_* are rewritten so they use the
NCONF_* functions internally.
In addition to that, I've split the old conf.c code into two files,
conf_def.c and conf_api.c. conf_def.c contains the default config
object that reads a configuration file the standard OpenSSL way, as
well as configuration file with Win32 registry file syntax (I'm not
sure I got that one right). conf_api.c provides an API to build other
configuration file readers around (can you see a configuraion file in
XML? I can :-)).
Finally, I've changed the name conf_lcl.h to conf_def.h, since it's
made specifically for that "class" and none others.
2000-04-09 20:04:35 +08:00
|
|
|
if (IS_ESC(conf, *p)) {
|
2000-06-06 23:21:12 +08:00
|
|
|
p = scan_esc(conf, p);
|
1998-12-21 18:52:47 +08:00
|
|
|
continue;
|
|
|
|
}
|
2019-05-06 16:50:35 +08:00
|
|
|
if (!(IS_ALNUM_PUNCT(conf, *p)
|
|
|
|
|| (conf->flag_dollarid && IS_DOLLAR(conf, *p))))
|
2017-07-06 12:56:20 +08:00
|
|
|
return p;
|
1998-12-21 18:52:47 +08:00
|
|
|
p++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
I've always wanted to make the CONF library more adaptable. Here's
the result.
I have retained the old behavior of the CONF_* functions, and have
added a more "object oriented" interface through NCONF_* functions
(New CONF, you see :-)), working the same way as, for example, the
BIO interface. Really, the CONF_* are rewritten so they use the
NCONF_* functions internally.
In addition to that, I've split the old conf.c code into two files,
conf_def.c and conf_api.c. conf_def.c contains the default config
object that reads a configuration file the standard OpenSSL way, as
well as configuration file with Win32 registry file syntax (I'm not
sure I got that one right). conf_api.c provides an API to build other
configuration file readers around (can you see a configuraion file in
XML? I can :-)).
Finally, I've changed the name conf_lcl.h to conf_def.h, since it's
made specifically for that "class" and none others.
2000-04-09 20:04:35 +08:00
|
|
|
static char *scan_quote(CONF *conf, char *p)
|
1998-12-21 18:52:47 +08:00
|
|
|
{
|
I've always wanted to make the CONF library more adaptable. Here's
the result.
I have retained the old behavior of the CONF_* functions, and have
added a more "object oriented" interface through NCONF_* functions
(New CONF, you see :-)), working the same way as, for example, the
BIO interface. Really, the CONF_* are rewritten so they use the
NCONF_* functions internally.
In addition to that, I've split the old conf.c code into two files,
conf_def.c and conf_api.c. conf_def.c contains the default config
object that reads a configuration file the standard OpenSSL way, as
well as configuration file with Win32 registry file syntax (I'm not
sure I got that one right). conf_api.c provides an API to build other
configuration file readers around (can you see a configuraion file in
XML? I can :-)).
Finally, I've changed the name conf_lcl.h to conf_def.h, since it's
made specifically for that "class" and none others.
2000-04-09 20:04:35 +08:00
|
|
|
int q = *p;
|
2015-01-22 11:40:55 +08:00
|
|
|
|
I've always wanted to make the CONF library more adaptable. Here's
the result.
I have retained the old behavior of the CONF_* functions, and have
added a more "object oriented" interface through NCONF_* functions
(New CONF, you see :-)), working the same way as, for example, the
BIO interface. Really, the CONF_* are rewritten so they use the
NCONF_* functions internally.
In addition to that, I've split the old conf.c code into two files,
conf_def.c and conf_api.c. conf_def.c contains the default config
object that reads a configuration file the standard OpenSSL way, as
well as configuration file with Win32 registry file syntax (I'm not
sure I got that one right). conf_api.c provides an API to build other
configuration file readers around (can you see a configuraion file in
XML? I can :-)).
Finally, I've changed the name conf_lcl.h to conf_def.h, since it's
made specifically for that "class" and none others.
2000-04-09 20:04:35 +08:00
|
|
|
p++;
|
|
|
|
while (!(IS_EOF(conf, *p)) && (*p != q)) {
|
|
|
|
if (IS_ESC(conf, *p)) {
|
|
|
|
p++;
|
|
|
|
if (IS_EOF(conf, *p))
|
2017-07-06 12:56:20 +08:00
|
|
|
return p;
|
I've always wanted to make the CONF library more adaptable. Here's
the result.
I have retained the old behavior of the CONF_* functions, and have
added a more "object oriented" interface through NCONF_* functions
(New CONF, you see :-)), working the same way as, for example, the
BIO interface. Really, the CONF_* are rewritten so they use the
NCONF_* functions internally.
In addition to that, I've split the old conf.c code into two files,
conf_def.c and conf_api.c. conf_def.c contains the default config
object that reads a configuration file the standard OpenSSL way, as
well as configuration file with Win32 registry file syntax (I'm not
sure I got that one right). conf_api.c provides an API to build other
configuration file readers around (can you see a configuraion file in
XML? I can :-)).
Finally, I've changed the name conf_lcl.h to conf_def.h, since it's
made specifically for that "class" and none others.
2000-04-09 20:04:35 +08:00
|
|
|
}
|
|
|
|
p++;
|
1998-12-21 18:52:47 +08:00
|
|
|
}
|
I've always wanted to make the CONF library more adaptable. Here's
the result.
I have retained the old behavior of the CONF_* functions, and have
added a more "object oriented" interface through NCONF_* functions
(New CONF, you see :-)), working the same way as, for example, the
BIO interface. Really, the CONF_* are rewritten so they use the
NCONF_* functions internally.
In addition to that, I've split the old conf.c code into two files,
conf_def.c and conf_api.c. conf_def.c contains the default config
object that reads a configuration file the standard OpenSSL way, as
well as configuration file with Win32 registry file syntax (I'm not
sure I got that one right). conf_api.c provides an API to build other
configuration file readers around (can you see a configuraion file in
XML? I can :-)).
Finally, I've changed the name conf_lcl.h to conf_def.h, since it's
made specifically for that "class" and none others.
2000-04-09 20:04:35 +08:00
|
|
|
if (*p == q)
|
|
|
|
p++;
|
2017-07-06 12:56:20 +08:00
|
|
|
return p;
|
1998-12-21 18:52:47 +08:00
|
|
|
}
|
I've always wanted to make the CONF library more adaptable. Here's
the result.
I have retained the old behavior of the CONF_* functions, and have
added a more "object oriented" interface through NCONF_* functions
(New CONF, you see :-)), working the same way as, for example, the
BIO interface. Really, the CONF_* are rewritten so they use the
NCONF_* functions internally.
In addition to that, I've split the old conf.c code into two files,
conf_def.c and conf_api.c. conf_def.c contains the default config
object that reads a configuration file the standard OpenSSL way, as
well as configuration file with Win32 registry file syntax (I'm not
sure I got that one right). conf_api.c provides an API to build other
configuration file readers around (can you see a configuraion file in
XML? I can :-)).
Finally, I've changed the name conf_lcl.h to conf_def.h, since it's
made specifically for that "class" and none others.
2000-04-09 20:04:35 +08:00
|
|
|
|
|
|
|
static char *scan_dquote(CONF *conf, char *p)
|
1998-12-21 18:52:47 +08:00
|
|
|
{
|
|
|
|
int q = *p;
|
2015-01-22 11:40:55 +08:00
|
|
|
|
1998-12-21 18:52:47 +08:00
|
|
|
p++;
|
I've always wanted to make the CONF library more adaptable. Here's
the result.
I have retained the old behavior of the CONF_* functions, and have
added a more "object oriented" interface through NCONF_* functions
(New CONF, you see :-)), working the same way as, for example, the
BIO interface. Really, the CONF_* are rewritten so they use the
NCONF_* functions internally.
In addition to that, I've split the old conf.c code into two files,
conf_def.c and conf_api.c. conf_def.c contains the default config
object that reads a configuration file the standard OpenSSL way, as
well as configuration file with Win32 registry file syntax (I'm not
sure I got that one right). conf_api.c provides an API to build other
configuration file readers around (can you see a configuraion file in
XML? I can :-)).
Finally, I've changed the name conf_lcl.h to conf_def.h, since it's
made specifically for that "class" and none others.
2000-04-09 20:04:35 +08:00
|
|
|
while (!(IS_EOF(conf, *p))) {
|
|
|
|
if (*p == q) {
|
|
|
|
if (*(p + 1) == q) {
|
|
|
|
p++;
|
|
|
|
} else {
|
|
|
|
break;
|
2015-01-22 11:40:55 +08:00
|
|
|
}
|
I've always wanted to make the CONF library more adaptable. Here's
the result.
I have retained the old behavior of the CONF_* functions, and have
added a more "object oriented" interface through NCONF_* functions
(New CONF, you see :-)), working the same way as, for example, the
BIO interface. Really, the CONF_* are rewritten so they use the
NCONF_* functions internally.
In addition to that, I've split the old conf.c code into two files,
conf_def.c and conf_api.c. conf_def.c contains the default config
object that reads a configuration file the standard OpenSSL way, as
well as configuration file with Win32 registry file syntax (I'm not
sure I got that one right). conf_api.c provides an API to build other
configuration file readers around (can you see a configuraion file in
XML? I can :-)).
Finally, I've changed the name conf_lcl.h to conf_def.h, since it's
made specifically for that "class" and none others.
2000-04-09 20:04:35 +08:00
|
|
|
}
|
1998-12-21 18:52:47 +08:00
|
|
|
p++;
|
|
|
|
}
|
|
|
|
if (*p == q)
|
|
|
|
p++;
|
2017-07-06 12:56:20 +08:00
|
|
|
return p;
|
1998-12-21 18:52:47 +08:00
|
|
|
}
|
|
|
|
|
2015-12-25 00:20:54 +08:00
|
|
|
static void dump_value_doall_arg(const CONF_VALUE *a, BIO *out)
|
I've always wanted to make the CONF library more adaptable. Here's
the result.
I have retained the old behavior of the CONF_* functions, and have
added a more "object oriented" interface through NCONF_* functions
(New CONF, you see :-)), working the same way as, for example, the
BIO interface. Really, the CONF_* are rewritten so they use the
NCONF_* functions internally.
In addition to that, I've split the old conf.c code into two files,
conf_def.c and conf_api.c. conf_def.c contains the default config
object that reads a configuration file the standard OpenSSL way, as
well as configuration file with Win32 registry file syntax (I'm not
sure I got that one right). conf_api.c provides an API to build other
configuration file readers around (can you see a configuraion file in
XML? I can :-)).
Finally, I've changed the name conf_lcl.h to conf_def.h, since it's
made specifically for that "class" and none others.
2000-04-09 20:04:35 +08:00
|
|
|
{
|
|
|
|
if (a->name)
|
|
|
|
BIO_printf(out, "[%s] %s=%s\n", a->section, a->name, a->value);
|
|
|
|
else
|
|
|
|
BIO_printf(out, "[[%s]]\n", a->section);
|
|
|
|
}
|
|
|
|
|
2015-12-25 00:20:54 +08:00
|
|
|
IMPLEMENT_LHASH_DOALL_ARG_CONST(CONF_VALUE, BIO);
|
2001-01-09 08:24:38 +08:00
|
|
|
|
2002-01-19 00:51:05 +08:00
|
|
|
static int def_dump(const CONF *conf, BIO *out)
|
1998-12-21 18:52:47 +08:00
|
|
|
{
|
2015-12-25 00:20:54 +08:00
|
|
|
lh_CONF_VALUE_doall_BIO(conf->data, dump_value_doall_arg, out);
|
I've always wanted to make the CONF library more adaptable. Here's
the result.
I have retained the old behavior of the CONF_* functions, and have
added a more "object oriented" interface through NCONF_* functions
(New CONF, you see :-)), working the same way as, for example, the
BIO interface. Really, the CONF_* are rewritten so they use the
NCONF_* functions internally.
In addition to that, I've split the old conf.c code into two files,
conf_def.c and conf_api.c. conf_def.c contains the default config
object that reads a configuration file the standard OpenSSL way, as
well as configuration file with Win32 registry file syntax (I'm not
sure I got that one right). conf_api.c provides an API to build other
configuration file readers around (can you see a configuraion file in
XML? I can :-)).
Finally, I've changed the name conf_lcl.h to conf_def.h, since it's
made specifically for that "class" and none others.
2000-04-09 20:04:35 +08:00
|
|
|
return 1;
|
|
|
|
}
|
1998-12-21 18:52:47 +08:00
|
|
|
|
2002-01-19 00:51:05 +08:00
|
|
|
static int def_is_number(const CONF *conf, char c)
|
I've always wanted to make the CONF library more adaptable. Here's
the result.
I have retained the old behavior of the CONF_* functions, and have
added a more "object oriented" interface through NCONF_* functions
(New CONF, you see :-)), working the same way as, for example, the
BIO interface. Really, the CONF_* are rewritten so they use the
NCONF_* functions internally.
In addition to that, I've split the old conf.c code into two files,
conf_def.c and conf_api.c. conf_def.c contains the default config
object that reads a configuration file the standard OpenSSL way, as
well as configuration file with Win32 registry file syntax (I'm not
sure I got that one right). conf_api.c provides an API to build other
configuration file readers around (can you see a configuraion file in
XML? I can :-)).
Finally, I've changed the name conf_lcl.h to conf_def.h, since it's
made specifically for that "class" and none others.
2000-04-09 20:04:35 +08:00
|
|
|
{
|
|
|
|
return IS_NUMBER(conf, c);
|
|
|
|
}
|
1998-12-21 18:52:47 +08:00
|
|
|
|
2002-01-19 00:51:05 +08:00
|
|
|
static int def_to_int(const CONF *conf, char c)
|
I've always wanted to make the CONF library more adaptable. Here's
the result.
I have retained the old behavior of the CONF_* functions, and have
added a more "object oriented" interface through NCONF_* functions
(New CONF, you see :-)), working the same way as, for example, the
BIO interface. Really, the CONF_* are rewritten so they use the
NCONF_* functions internally.
In addition to that, I've split the old conf.c code into two files,
conf_def.c and conf_api.c. conf_def.c contains the default config
object that reads a configuration file the standard OpenSSL way, as
well as configuration file with Win32 registry file syntax (I'm not
sure I got that one right). conf_api.c provides an API to build other
configuration file readers around (can you see a configuraion file in
XML? I can :-)).
Finally, I've changed the name conf_lcl.h to conf_def.h, since it's
made specifically for that "class" and none others.
2000-04-09 20:04:35 +08:00
|
|
|
{
|
|
|
|
return c - '0';
|
1998-12-21 18:52:47 +08:00
|
|
|
}
|