Cleanup OPENSSL_NO_xxx, part 1
[openssl.git] / crypto / x509v3 / v3_alt.c
index 2c2d6c44421a8d83494bf3cdca3de41d3e1688ce..ea1410dd74e3fa202d1a25f1e58af05e11c66a6c 100644 (file)
@@ -1,5 +1,5 @@
 /* v3_alt.c */
 /* v3_alt.c */
-/* Written by Dr Stephen N Henson (shenson@bigfoot.com) for the OpenSSL
+/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
  * project.
  */
 /* ====================================================================
  * project.
  */
 /* ====================================================================
@@ -366,6 +366,7 @@ static int copy_email(X509V3_CTX *ctx, GENERAL_NAMES *gens, int move_p)
                 if (move_p)
                         {
                         X509_NAME_delete_entry(nm, i);
                 if (move_p)
                         {
                         X509_NAME_delete_entry(nm, i);
+                       X509_NAME_ENTRY_free(ne);
                         i--;
                         }
                if(!email || !(gen = GENERAL_NAME_new())) {
                         i--;
                         }
                if(!email || !(gen = GENERAL_NAME_new())) {
@@ -392,8 +393,8 @@ static int copy_email(X509V3_CTX *ctx, GENERAL_NAMES *gens, int move_p)
        
 }
 
        
 }
 
-GENERAL_NAMES *v2i_GENERAL_NAMES(X509V3_EXT_METHOD *method,
-                               X509V3_CTX *ctx, STACK_OF(CONF_VALUE) *nval)
+GENERAL_NAMES *v2i_GENERAL_NAMES(const X509V3_EXT_METHOD *method,
+                                X509V3_CTX *ctx, STACK_OF(CONF_VALUE) *nval)
 {
        GENERAL_NAME *gen;
        GENERAL_NAMES *gens = NULL;
 {
        GENERAL_NAME *gen;
        GENERAL_NAMES *gens = NULL;
@@ -414,15 +415,15 @@ GENERAL_NAMES *v2i_GENERAL_NAMES(X509V3_EXT_METHOD *method,
        return NULL;
 }
 
        return NULL;
 }
 
-GENERAL_NAME *v2i_GENERAL_NAME(X509V3_EXT_METHOD *method, X509V3_CTX *ctx,
-                                                        CONF_VALUE *cnf)
+GENERAL_NAME *v2i_GENERAL_NAME(const X509V3_EXT_METHOD *method, X509V3_CTX *ctx,
+                              CONF_VALUE *cnf)
        {
        return v2i_GENERAL_NAME_ex(NULL, method, ctx, cnf, 0);
        }
 
 GENERAL_NAME *a2i_GENERAL_NAME(GENERAL_NAME *out,
        {
        return v2i_GENERAL_NAME_ex(NULL, method, ctx, cnf, 0);
        }
 
 GENERAL_NAME *a2i_GENERAL_NAME(GENERAL_NAME *out,
-                               X509V3_EXT_METHOD *method, X509V3_CTX *ctx,
-                               int gen_type, char *value, int is_nc)
+                              const X509V3_EXT_METHOD *method, X509V3_CTX *ctx,
+                              int gen_type, char *value, int is_nc)
        {
        char is_string = 0;
        GENERAL_NAME *gen = NULL;
        {
        char is_string = 0;
        GENERAL_NAME *gen = NULL;
@@ -464,6 +465,7 @@ GENERAL_NAME *a2i_GENERAL_NAME(GENERAL_NAME *out,
                        }
                gen->d.rid = obj;
                }
                        }
                gen->d.rid = obj;
                }
+               break;
 
                case GEN_IPADD:
                if (is_nc)
 
                case GEN_IPADD:
                if (is_nc)
@@ -492,6 +494,7 @@ GENERAL_NAME *a2i_GENERAL_NAME(GENERAL_NAME *out,
                        X509V3err(X509V3_F_A2I_GENERAL_NAME,X509V3_R_OTHERNAME_ERROR);
                        goto err;
                        }
                        X509V3err(X509V3_F_A2I_GENERAL_NAME,X509V3_R_OTHERNAME_ERROR);
                        goto err;
                        }
+               break;
                default:
                X509V3err(X509V3_F_A2I_GENERAL_NAME,X509V3_R_UNSUPPORTED_TYPE);
                goto err;
                default:
                X509V3err(X509V3_F_A2I_GENERAL_NAME,X509V3_R_UNSUPPORTED_TYPE);
                goto err;
@@ -513,13 +516,14 @@ GENERAL_NAME *a2i_GENERAL_NAME(GENERAL_NAME *out,
        return gen;
 
        err:
        return gen;
 
        err:
-       GENERAL_NAME_free(gen);
+       if (!out)
+               GENERAL_NAME_free(gen);
        return NULL;
        }
 
 GENERAL_NAME *v2i_GENERAL_NAME_ex(GENERAL_NAME *out,
        return NULL;
        }
 
 GENERAL_NAME *v2i_GENERAL_NAME_ex(GENERAL_NAME *out,
-                               X509V3_EXT_METHOD *method, X509V3_CTX *ctx,
-                                                CONF_VALUE *cnf, int is_nc)
+                                 const X509V3_EXT_METHOD *method,
+                                 X509V3_CTX *ctx, CONF_VALUE *cnf, int is_nc)
        {
        int type;
 
        {
        int type;
 
@@ -575,6 +579,8 @@ static int do_othername(GENERAL_NAME *gen, char *value, X509V3_CTX *ctx)
                return 0;
        objlen = p - value;
        objtmp = OPENSSL_malloc(objlen + 1);
                return 0;
        objlen = p - value;
        objtmp = OPENSSL_malloc(objlen + 1);
+       if (objtmp == NULL)
+               return 0;
        strncpy(objtmp, value, objlen);
        objtmp[objlen] = 0;
        gen->d.otherName->type_id = OBJ_txt2obj(objtmp, 0);
        strncpy(objtmp, value, objlen);
        objtmp[objlen] = 0;
        gen->d.otherName->type_id = OBJ_txt2obj(objtmp, 0);
@@ -604,6 +610,7 @@ static int do_dirname(GENERAL_NAME *gen, char *value, X509V3_CTX *ctx)
        if (!ret)
                X509_NAME_free(nm);
        gen->d.dirn = nm;
        if (!ret)
                X509_NAME_free(nm);
        gen->d.dirn = nm;
+       X509V3_section_free(ctx, sk);
                
        return ret;
        }
                
        return ret;
        }