Fix various incorrect error function codes.
[openssl.git] / crypto / conf / conf_def.c
index 0451be01538d1d2f26a9161bd6ebec3e2736e7fd..f14de2293ecff0f440039ce530dc0ff6a51e55a1 100644 (file)
@@ -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_CONF_LOAD,CONF_R_NO_SUCH_FILE);
+                       CONFerr(CONF_F_DEF_LOAD,CONF_R_NO_SUCH_FILE);
                else
                else
-                       CONFerr(CONF_F_CONF_LOAD,ERR_R_SYS_LIB);
+                       CONFerr(CONF_F_DEF_LOAD,ERR_R_SYS_LIB);
                return 0;
                }
 
                return 0;
                }
 
@@ -225,28 +225,28 @@ static int def_load_bio(CONF *conf, BIO *in, long *line)
 
        if ((buff=BUF_MEM_new()) == NULL)
                {
 
        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)
                {
                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)
                {
                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)
                {
                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;
                }
                                        CONF_R_UNABLE_TO_CREATE_NEW_SECTION);
                goto err;
                }
@@ -258,7 +258,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_CONF_LOAD_BIO,ERR_R_BUF_LIB);
+                       CONFerr(CONF_F_DEF_LOAD_BIO,ERR_R_BUF_LIB);
                        goto err;
                        }
                p= &(buff->data[bufnum]);
                        goto err;
                        }
                p= &(buff->data[bufnum]);
@@ -329,7 +329,7 @@ again:
                                        ss=p;
                                        goto again;
                                        }
                                        ss=p;
                                        goto again;
                                        }
-                               CONFerr(CONF_F_CONF_LOAD_BIO,
+                               CONFerr(CONF_F_DEF_LOAD_BIO,
                                        CONF_R_MISSING_CLOSE_SQUARE_BRACKET);
                                goto err;
                                }
                                        CONF_R_MISSING_CLOSE_SQUARE_BRACKET);
                                goto err;
                                }
@@ -339,7 +339,7 @@ again:
                                sv=_CONF_new_section(conf,section);
                        if (sv == NULL)
                                {
                                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;
                                }
                                        CONF_R_UNABLE_TO_CREATE_NEW_SECTION);
                                goto err;
                                }
@@ -362,7 +362,7 @@ again:
                        p=eat_ws(conf, end);
                        if (*p != '=')
                                {
                        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;
                                }
                                                CONF_R_MISSING_EQUAL_SIGN);
                                goto err;
                                }
@@ -379,7 +379,7 @@ again:
 
                        if (!(v=(CONF_VALUE *)OPENSSL_malloc(sizeof(CONF_VALUE))))
                                {
 
                        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;
                                }
                                                        ERR_R_MALLOC_FAILURE);
                                goto err;
                                }
@@ -388,7 +388,7 @@ again:
                        v->value=NULL;
                        if (v->name == NULL)
                                {
                        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;
                                }
                                                        ERR_R_MALLOC_FAILURE);
                                goto err;
                                }
@@ -402,7 +402,7 @@ again:
                                        tv=_CONF_new_section(conf,psection);
                                if (tv == NULL)
                                        {
                                        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;
                                        }
                                           CONF_R_UNABLE_TO_CREATE_NEW_SECTION);
                                        goto err;
                                        }
@@ -416,7 +416,7 @@ again:
 #if 1
                        if (_CONF_add_string(conf, tv, v) == 0)
                                {
 #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;
                                }
                                                        ERR_R_MALLOC_FAILURE);
                                goto err;
                                }
@@ -424,7 +424,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_CONF_LOAD_BIO,
+                               CONFerr(CONF_F_DEF_LOAD_BIO,
                                                        ERR_R_MALLOC_FAILURE);
                                goto err;
                                }
                                                        ERR_R_MALLOC_FAILURE);
                                goto err;
                                }
@@ -632,6 +632,11 @@ 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++);
                        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;
                        }
                else
                        from=e;
                        }
                else