projects
/
oweals
/
openssl.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
arm_arch.h: allow to specify __ARM_ARCH__ elsewhere.
[oweals/openssl.git]
/
crypto
/
conf
/
conf_def.c
diff --git
a/crypto/conf/conf_def.c
b/crypto/conf/conf_def.c
index 57d2739ae0c89feae8ea4518d6029a4721a55531..cf951320af8ee344e60d4fd863be34dc3cebce8c 100644
(file)
--- a/
crypto/conf/conf_def.c
+++ b/
crypto/conf/conf_def.c
@@
-60,6
+60,7
@@
#include <stdio.h>
#include <string.h>
#include <stdio.h>
#include <string.h>
+#include "cryptlib.h"
#include <openssl/stack.h>
#include <openssl/lhash.h>
#include <openssl/conf.h>
#include <openssl/stack.h>
#include <openssl/lhash.h>
#include <openssl/conf.h>
@@
-67,7
+68,6
@@
#include "conf_def.h"
#include <openssl/buffer.h>
#include <openssl/err.h>
#include "conf_def.h"
#include <openssl/buffer.h>
#include <openssl/err.h>
-#include "cryptlib.h"
static char *eat_ws(CONF *conf, char *p);
static char *eat_alpha_numeric(CONF *conf, char *p);
static char *eat_ws(CONF *conf, char *p);
static char *eat_alpha_numeric(CONF *conf, char *p);
@@
-88,7
+88,7
@@
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);
static int def_is_number(const CONF *conf, char c);
static int def_to_int(const CONF *conf, char c);
-const char
*CONF_def_version
="CONF_def" OPENSSL_VERSION_PTEXT;
+const char
CONF_def_version[]
="CONF_def" OPENSSL_VERSION_PTEXT;
static CONF_METHOD default_method = {
"OpenSSL default",
static CONF_METHOD default_method = {
"OpenSSL default",
@@
-129,7
+129,7
@@
static CONF *def_create(CONF_METHOD *meth)
{
CONF *ret;
{
CONF *ret;
- ret =
(CONF *)
OPENSSL_malloc(sizeof(CONF) + sizeof(unsigned short *));
+ ret = OPENSSL_malloc(sizeof(CONF) + sizeof(unsigned short *));
if (ret)
if (meth->init(ret) == 0)
{
if (ret)
if (meth->init(ret) == 0)
{
@@
-145,7
+145,7
@@
static int def_init_default(CONF *conf)
return 0;
conf->meth = &default_method;
return 0;
conf->meth = &default_method;
- conf->meth_data =
(void *)
CONF_type_default;
+ conf->meth_data = CONF_type_default;
conf->data = NULL;
return 1;
conf->data = NULL;
return 1;
@@
-194,9
+194,9
@@
static int def_load(CONF *conf, const char *name, long *line)
if (in == NULL)
{
if (ERR_GET_REASON(ERR_peek_last_error()) == BIO_R_NO_SUCH_FILE)
if (in == NULL)
{
if (ERR_GET_REASON(ERR_peek_last_error()) == BIO_R_NO_SUCH_FILE)
- CONFerr(CONF_F_
CON
F_LOAD,CONF_R_NO_SUCH_FILE);
+ CONFerr(CONF_F_
DE
F_LOAD,CONF_R_NO_SUCH_FILE);
else
else
- CONFerr(CONF_F_
CON
F_LOAD,ERR_R_SYS_LIB);
+ CONFerr(CONF_F_
DE
F_LOAD,ERR_R_SYS_LIB);
return 0;
}
return 0;
}
@@
-213,44
+213,42
@@
static int def_load_bio(CONF *conf, BIO *in, long *line)
int bufnum=0,i,ii;
BUF_MEM *buff=NULL;
char *s,*p,*end;
int bufnum=0,i,ii;
BUF_MEM *buff=NULL;
char *s,*p,*end;
- int again
,n
;
+ int again;
long eline=0;
char btmp[DECIMAL_SIZE(eline)+1];
CONF_VALUE *v=NULL,*tv;
CONF_VALUE *sv=NULL;
char *section=NULL,*buf;
long eline=0;
char btmp[DECIMAL_SIZE(eline)+1];
CONF_VALUE *v=NULL,*tv;
CONF_VALUE *sv=NULL;
char *section=NULL,*buf;
- STACK_OF(CONF_VALUE) *section_sk=NULL,*ts;
char *start,*psection,*pname;
void *h = (void *)(conf->data);
if ((buff=BUF_MEM_new()) == NULL)
{
char *start,*psection,*pname;
void *h = (void *)(conf->data);
if ((buff=BUF_MEM_new()) == NULL)
{
- CONFerr(CONF_F_
CON
F_LOAD_BIO,ERR_R_BUF_LIB);
+ CONFerr(CONF_F_
DE
F_LOAD_BIO,ERR_R_BUF_LIB);
goto err;
}
section=(char *)OPENSSL_malloc(10);
if (section == NULL)
{
goto err;
}
section=(char *)OPENSSL_malloc(10);
if (section == NULL)
{
- CONFerr(CONF_F_
CON
F_LOAD_BIO,ERR_R_MALLOC_FAILURE);
+ CONFerr(CONF_F_
DE
F_LOAD_BIO,ERR_R_MALLOC_FAILURE);
goto err;
}
goto err;
}
-
strcpy(section,"default"
);
+
BUF_strlcpy(section,"default",10
);
if (_CONF_new_data(conf) == 0)
{
if (_CONF_new_data(conf) == 0)
{
- CONFerr(CONF_F_
CON
F_LOAD_BIO,ERR_R_MALLOC_FAILURE);
+ CONFerr(CONF_F_
DE
F_LOAD_BIO,ERR_R_MALLOC_FAILURE);
goto err;
}
sv=_CONF_new_section(conf,section);
if (sv == NULL)
{
goto err;
}
sv=_CONF_new_section(conf,section);
if (sv == NULL)
{
- CONFerr(CONF_F_
CON
F_LOAD_BIO,
+ CONFerr(CONF_F_
DE
F_LOAD_BIO,
CONF_R_UNABLE_TO_CREATE_NEW_SECTION);
goto err;
}
CONF_R_UNABLE_TO_CREATE_NEW_SECTION);
goto err;
}
- section_sk=(STACK_OF(CONF_VALUE) *)sv->value;
bufnum=0;
again=0;
bufnum=0;
again=0;
@@
-258,7
+256,7
@@
static int def_load_bio(CONF *conf, BIO *in, long *line)
{
if (!BUF_MEM_grow(buff,bufnum+CONFBUFSIZE))
{
{
if (!BUF_MEM_grow(buff,bufnum+CONFBUFSIZE))
{
- CONFerr(CONF_F_
CON
F_LOAD_BIO,ERR_R_BUF_LIB);
+ CONFerr(CONF_F_
DE
F_LOAD_BIO,ERR_R_BUF_LIB);
goto err;
}
p= &(buff->data[bufnum]);
goto err;
}
p= &(buff->data[bufnum]);
@@
-309,7
+307,6
@@
static int def_load_bio(CONF *conf, BIO *in, long *line)
buf=buff->data;
clear_comments(conf, buf);
buf=buff->data;
clear_comments(conf, buf);
- n=strlen(buf);
s=eat_ws(conf, buf);
if (IS_EOF(conf,*s)) continue; /* blank line */
if (*s == '[')
s=eat_ws(conf, buf);
if (IS_EOF(conf,*s)) continue; /* blank line */
if (*s == '[')
@@
-329,7
+326,7
@@
again:
ss=p;
goto again;
}
ss=p;
goto again;
}
- CONFerr(CONF_F_
CON
F_LOAD_BIO,
+ CONFerr(CONF_F_
DE
F_LOAD_BIO,
CONF_R_MISSING_CLOSE_SQUARE_BRACKET);
goto err;
}
CONF_R_MISSING_CLOSE_SQUARE_BRACKET);
goto err;
}
@@
-339,11
+336,10
@@
again:
sv=_CONF_new_section(conf,section);
if (sv == NULL)
{
sv=_CONF_new_section(conf,section);
if (sv == NULL)
{
- CONFerr(CONF_F_
CON
F_LOAD_BIO,
+ CONFerr(CONF_F_
DE
F_LOAD_BIO,
CONF_R_UNABLE_TO_CREATE_NEW_SECTION);
goto err;
}
CONF_R_UNABLE_TO_CREATE_NEW_SECTION);
goto err;
}
- section_sk=(STACK_OF(CONF_VALUE) *)sv->value;
continue;
}
else
continue;
}
else
@@
-362,7
+358,7
@@
again:
p=eat_ws(conf, end);
if (*p != '=')
{
p=eat_ws(conf, end);
if (*p != '=')
{
- CONFerr(CONF_F_
CON
F_LOAD_BIO,
+ CONFerr(CONF_F_
DE
F_LOAD_BIO,
CONF_R_MISSING_EQUAL_SIGN);
goto err;
}
CONF_R_MISSING_EQUAL_SIGN);
goto err;
}
@@
-379,7
+375,7
@@
again:
if (!(v=(CONF_VALUE *)OPENSSL_malloc(sizeof(CONF_VALUE))))
{
if (!(v=(CONF_VALUE *)OPENSSL_malloc(sizeof(CONF_VALUE))))
{
- CONFerr(CONF_F_
CON
F_LOAD_BIO,
+ CONFerr(CONF_F_
DE
F_LOAD_BIO,
ERR_R_MALLOC_FAILURE);
goto err;
}
ERR_R_MALLOC_FAILURE);
goto err;
}
@@
-388,11
+384,11
@@
again:
v->value=NULL;
if (v->name == NULL)
{
v->value=NULL;
if (v->name == NULL)
{
- CONFerr(CONF_F_
CON
F_LOAD_BIO,
+ CONFerr(CONF_F_
DE
F_LOAD_BIO,
ERR_R_MALLOC_FAILURE);
goto err;
}
ERR_R_MALLOC_FAILURE);
goto err;
}
-
strcpy(v->name,pname
);
+
BUF_strlcpy(v->name,pname,strlen(pname)+1
);
if (!str_copy(conf,psection,&(v->value),start)) goto err;
if (strcmp(psection,section) != 0)
if (!str_copy(conf,psection,&(v->value),start)) goto err;
if (strcmp(psection,section) != 0)
@@
-402,21
+398,17
@@
again:
tv=_CONF_new_section(conf,psection);
if (tv == NULL)
{
tv=_CONF_new_section(conf,psection);
if (tv == NULL)
{
- CONFerr(CONF_F_
CON
F_LOAD_BIO,
+ CONFerr(CONF_F_
DE
F_LOAD_BIO,
CONF_R_UNABLE_TO_CREATE_NEW_SECTION);
goto err;
}
CONF_R_UNABLE_TO_CREATE_NEW_SECTION);
goto err;
}
- ts=(STACK_OF(CONF_VALUE) *)tv->value;
}
else
}
else
- {
tv=sv;
tv=sv;
- ts=section_sk;
- }
#if 1
if (_CONF_add_string(conf, tv, v) == 0)
{
#if 1
if (_CONF_add_string(conf, tv, v) == 0)
{
- CONFerr(CONF_F_
CON
F_LOAD_BIO,
+ CONFerr(CONF_F_
DE
F_LOAD_BIO,
ERR_R_MALLOC_FAILURE);
goto err;
}
ERR_R_MALLOC_FAILURE);
goto err;
}
@@
-424,7
+416,7
@@
again:
v->section=tv->section;
if (!sk_CONF_VALUE_push(ts,v))
{
v->section=tv->section;
if (!sk_CONF_VALUE_push(ts,v))
{
- CONFerr(CONF_F_
CON
F_LOAD_BIO,
+ CONFerr(CONF_F_
DE
F_LOAD_BIO,
ERR_R_MALLOC_FAILURE);
goto err;
}
ERR_R_MALLOC_FAILURE);
goto err;
}
@@
-447,7
+439,7
@@
err:
if (buff != NULL) BUF_MEM_free(buff);
if (section != NULL) OPENSSL_free(section);
if (line != NULL) *line=eline;
if (buff != NULL) BUF_MEM_free(buff);
if (section != NULL) OPENSSL_free(section);
if (line != NULL) *line=eline;
-
sprintf(
btmp,"%ld",eline);
+
BIO_snprintf(btmp,sizeof
btmp,"%ld",eline);
ERR_add_error_data(2,"line ",btmp);
if ((h != conf->data) && (conf->data != NULL))
{
ERR_add_error_data(2,"line ",btmp);
if ((h != conf->data) && (conf->data != NULL))
{
@@
-465,9
+457,6
@@
err:
static void clear_comments(CONF *conf, char *p)
{
static void clear_comments(CONF *conf, char *p)
{
- char *to;
-
- to=p;
for (;;)
{
if (IS_FCOMMENT(conf,*p))
for (;;)
{
if (IS_FCOMMENT(conf,*p))
@@
-613,13
+602,13
@@
static int str_copy(CONF *conf, char *section, char **pto, char *from)
e++;
}
/* So at this point we have
e++;
}
/* So at this point we have
- * n
s
which is the start of the name string which is
+ * n
p
which is the start of the name string which is
* '\0' terminated.
* '\0' terminated.
- * c
s
which is the start of the section string which is
+ * c
p
which is the start of the section string which is
* '\0' terminated.
* e is the 'next point after'.
* '\0' terminated.
* e is the 'next point after'.
- * r and
s
are the chars replaced by the '\0'
- * rp and
sp is where 'r' and 's
' came from.
+ * r and
rr
are the chars replaced by the '\0'
+ * rp and
rrp is where 'r' and 'rr
' came from.
*/
p=_CONF_get_string(conf,cp,np);
if (rrp != NULL) *rrp=rr;
*/
p=_CONF_get_string(conf,cp,np);
if (rrp != NULL) *rrp=rr;
@@
-629,10
+618,20
@@
static int str_copy(CONF *conf, char *section, char **pto, char *from)
CONFerr(CONF_F_STR_COPY,CONF_R_VARIABLE_HAS_NO_VALUE);
goto err;
}
CONFerr(CONF_F_STR_COPY,CONF_R_VARIABLE_HAS_NO_VALUE);
goto err;
}
- BUF_MEM_grow_clean(buf,(strlen(p)+
len
-(e-from)));
+ BUF_MEM_grow_clean(buf,(strlen(p)+
buf->length
-(e-from)));
while (*p)
buf->data[to++]= *(p++);
while (*p)
buf->data[to++]= *(p++);
+
+ /* Since we change the pointer 'from', we also have
+ to change the perceived length of the string it
+ points at. /RL */
+ len -= e-from;
from=e;
from=e;
+
+ /* 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;
}
else
buf->data[to++]= *(from++);
}
else
buf->data[to++]= *(from++);
@@
-712,7
+711,7
@@
static char *scan_dquote(CONF *conf, char *p)
return(p);
}
return(p);
}
-static void dump_value(CONF_VALUE *a, BIO *out)
+static void dump_value
_doall_arg
(CONF_VALUE *a, BIO *out)
{
if (a->name)
BIO_printf(out, "[%s] %s=%s\n", a->section, a->name, a->value);
{
if (a->name)
BIO_printf(out, "[%s] %s=%s\n", a->section, a->name, a->value);
@@
-720,11
+719,12
@@
static void dump_value(CONF_VALUE *a, BIO *out)
BIO_printf(out, "[[%s]]\n", a->section);
}
BIO_printf(out, "[[%s]]\n", a->section);
}
-static IMPLEMENT_LHASH_DOALL_ARG_FN(dump_value, CONF_VALUE
*, BIO *
)
+static IMPLEMENT_LHASH_DOALL_ARG_FN(dump_value, CONF_VALUE
, BIO
)
static int def_dump(const CONF *conf, BIO *out)
{
static int def_dump(const CONF *conf, BIO *out)
{
- lh_doall_arg(conf->data, LHASH_DOALL_ARG_FN(dump_value), out);
+ lh_CONF_VALUE_doall_arg(conf->data, LHASH_DOALL_ARG_FN(dump_value),
+ BIO, out);
return 1;
}
return 1;
}