X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=crypto%2Fconf%2Fconf_def.c;h=a168339b7db486ea21d1f6d9791724002ae09d47;hb=fee8d86d7aa2b449141eb68840681358475d5e07;hp=0451be01538d1d2f26a9161bd6ebec3e2736e7fd;hpb=d420ac2c7d4ba9d99ff2c257a3ad71ecc6d876e2;p=oweals%2Fopenssl.git diff --git a/crypto/conf/conf_def.c b/crypto/conf/conf_def.c index 0451be0153..a168339b7d 100644 --- a/crypto/conf/conf_def.c +++ b/crypto/conf/conf_def.c @@ -60,6 +60,7 @@ #include #include +#include "cryptlib.h" #include #include #include @@ -67,7 +68,6 @@ #include "conf_def.h" #include #include -#include "cryptlib.h" 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); -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", @@ -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) - CONFerr(CONF_F_CONF_LOAD,CONF_R_NO_SUCH_FILE); + CONFerr(CONF_F_DEF_LOAD,CONF_R_NO_SUCH_FILE); else - CONFerr(CONF_F_CONF_LOAD,ERR_R_SYS_LIB); + CONFerr(CONF_F_DEF_LOAD,ERR_R_SYS_LIB); return 0; } @@ -213,44 +213,45 @@ 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 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; - STACK_OF(CONF_VALUE) *section_sk=NULL,*ts; +/* STACK_OF(CONF_VALUE) *section_sk=NULL;*/ +/* STACK_OF(CONF_VALUE) *ts=NULL;*/ char *start,*psection,*pname; void *h = (void *)(conf->data); if ((buff=BUF_MEM_new()) == NULL) { - CONFerr(CONF_F_CONF_LOAD_BIO,ERR_R_BUF_LIB); + CONFerr(CONF_F_DEF_LOAD_BIO,ERR_R_BUF_LIB); goto err; } section=(char *)OPENSSL_malloc(10); if (section == NULL) { - CONFerr(CONF_F_CONF_LOAD_BIO,ERR_R_MALLOC_FAILURE); + CONFerr(CONF_F_DEF_LOAD_BIO,ERR_R_MALLOC_FAILURE); goto err; } BUF_strlcpy(section,"default",10); if (_CONF_new_data(conf) == 0) { - CONFerr(CONF_F_CONF_LOAD_BIO,ERR_R_MALLOC_FAILURE); + CONFerr(CONF_F_DEF_LOAD_BIO,ERR_R_MALLOC_FAILURE); goto err; } sv=_CONF_new_section(conf,section); if (sv == NULL) { - CONFerr(CONF_F_CONF_LOAD_BIO, + CONFerr(CONF_F_DEF_LOAD_BIO, CONF_R_UNABLE_TO_CREATE_NEW_SECTION); goto err; } - section_sk=(STACK_OF(CONF_VALUE) *)sv->value; +/* section_sk=(STACK_OF(CONF_VALUE) *)sv->value;*/ bufnum=0; again=0; @@ -258,7 +259,7 @@ static int def_load_bio(CONF *conf, BIO *in, long *line) { if (!BUF_MEM_grow(buff,bufnum+CONFBUFSIZE)) { - CONFerr(CONF_F_CONF_LOAD_BIO,ERR_R_BUF_LIB); + CONFerr(CONF_F_DEF_LOAD_BIO,ERR_R_BUF_LIB); goto err; } p= &(buff->data[bufnum]); @@ -309,7 +310,6 @@ static int def_load_bio(CONF *conf, BIO *in, long *line) 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 == '[') @@ -324,12 +324,12 @@ again: p=eat_ws(conf, end); if (*p != ']') { - if (*p != '\0') + if (*p != '\0' && ss != p) { ss=p; goto again; } - CONFerr(CONF_F_CONF_LOAD_BIO, + CONFerr(CONF_F_DEF_LOAD_BIO, CONF_R_MISSING_CLOSE_SQUARE_BRACKET); goto err; } @@ -339,11 +339,11 @@ again: sv=_CONF_new_section(conf,section); if (sv == NULL) { - CONFerr(CONF_F_CONF_LOAD_BIO, + CONFerr(CONF_F_DEF_LOAD_BIO, CONF_R_UNABLE_TO_CREATE_NEW_SECTION); goto err; } - section_sk=(STACK_OF(CONF_VALUE) *)sv->value; +/* section_sk=(STACK_OF(CONF_VALUE) *)sv->value;*/ continue; } else @@ -362,7 +362,7 @@ again: p=eat_ws(conf, end); if (*p != '=') { - CONFerr(CONF_F_CONF_LOAD_BIO, + CONFerr(CONF_F_DEF_LOAD_BIO, CONF_R_MISSING_EQUAL_SIGN); goto err; } @@ -379,7 +379,7 @@ again: if (!(v=(CONF_VALUE *)OPENSSL_malloc(sizeof(CONF_VALUE)))) { - CONFerr(CONF_F_CONF_LOAD_BIO, + CONFerr(CONF_F_DEF_LOAD_BIO, ERR_R_MALLOC_FAILURE); goto err; } @@ -388,7 +388,7 @@ again: v->value=NULL; if (v->name == NULL) { - CONFerr(CONF_F_CONF_LOAD_BIO, + CONFerr(CONF_F_DEF_LOAD_BIO, ERR_R_MALLOC_FAILURE); goto err; } @@ -402,21 +402,21 @@ again: tv=_CONF_new_section(conf,psection); if (tv == NULL) { - CONFerr(CONF_F_CONF_LOAD_BIO, + CONFerr(CONF_F_DEF_LOAD_BIO, CONF_R_UNABLE_TO_CREATE_NEW_SECTION); goto err; } - ts=(STACK_OF(CONF_VALUE) *)tv->value; +/* ts=(STACK_OF(CONF_VALUE) *)tv->value;*/ } else { tv=sv; - ts=section_sk; +/* ts=section_sk;*/ } #if 1 if (_CONF_add_string(conf, tv, v) == 0) { - CONFerr(CONF_F_CONF_LOAD_BIO, + CONFerr(CONF_F_DEF_LOAD_BIO, ERR_R_MALLOC_FAILURE); goto err; } @@ -424,7 +424,7 @@ again: v->section=tv->section; if (!sk_CONF_VALUE_push(ts,v)) { - CONFerr(CONF_F_CONF_LOAD_BIO, + CONFerr(CONF_F_DEF_LOAD_BIO, ERR_R_MALLOC_FAILURE); goto err; } @@ -465,9 +465,6 @@ err: static void clear_comments(CONF *conf, char *p) { - char *to; - - to=p; for (;;) { if (IS_FCOMMENT(conf,*p)) @@ -613,13 +610,13 @@ static int str_copy(CONF *conf, char *section, char **pto, char *from) e++; } /* So at this point we have - * ns which is the start of the name string which is + * np which is the start of the name string which is * '\0' terminated. - * cs which is the start of the section string which is + * cp which is the start of the section string which is * '\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; @@ -632,7 +629,17 @@ static int str_copy(CONF *conf, char *section, char **pto, char *from) BUF_MEM_grow_clean(buf,(strlen(p)+buf->length-(e-from))); 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; + + /* 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++);