diff options
Diffstat (limited to 'src/lib/libcrypto/asn1/tasn_fre.c')
| -rw-r--r-- | src/lib/libcrypto/asn1/tasn_fre.c | 37 |
1 files changed, 21 insertions, 16 deletions
diff --git a/src/lib/libcrypto/asn1/tasn_fre.c b/src/lib/libcrypto/asn1/tasn_fre.c index 5211276efe..9e6e7579f1 100644 --- a/src/lib/libcrypto/asn1/tasn_fre.c +++ b/src/lib/libcrypto/asn1/tasn_fre.c | |||
| @@ -10,7 +10,7 @@ | |||
| 10 | * are met: | 10 | * are met: |
| 11 | * | 11 | * |
| 12 | * 1. Redistributions of source code must retain the above copyright | 12 | * 1. Redistributions of source code must retain the above copyright |
| 13 | * notice, this list of conditions and the following disclaimer. | 13 | * notice, this list of conditions and the following disclaimer. |
| 14 | * | 14 | * |
| 15 | * 2. Redistributions in binary form must reproduce the above copyright | 15 | * 2. Redistributions in binary form must reproduce the above copyright |
| 16 | * notice, this list of conditions and the following disclaimer in | 16 | * notice, this list of conditions and the following disclaimer in |
| @@ -62,21 +62,25 @@ | |||
| 62 | #include <openssl/asn1t.h> | 62 | #include <openssl/asn1t.h> |
| 63 | #include <openssl/objects.h> | 63 | #include <openssl/objects.h> |
| 64 | 64 | ||
| 65 | static void asn1_item_combine_free(ASN1_VALUE **pval, const ASN1_ITEM *it, int combine); | 65 | static void asn1_item_combine_free(ASN1_VALUE **pval, const ASN1_ITEM *it, |
| 66 | int combine); | ||
| 66 | 67 | ||
| 67 | /* Free up an ASN1 structure */ | 68 | /* Free up an ASN1 structure */ |
| 68 | 69 | ||
| 69 | void ASN1_item_free(ASN1_VALUE *val, const ASN1_ITEM *it) | 70 | void |
| 71 | ASN1_item_free(ASN1_VALUE *val, const ASN1_ITEM *it) | ||
| 70 | { | 72 | { |
| 71 | asn1_item_combine_free(&val, it, 0); | 73 | asn1_item_combine_free(&val, it, 0); |
| 72 | } | 74 | } |
| 73 | 75 | ||
| 74 | void ASN1_item_ex_free(ASN1_VALUE **pval, const ASN1_ITEM *it) | 76 | void |
| 77 | ASN1_item_ex_free(ASN1_VALUE **pval, const ASN1_ITEM *it) | ||
| 75 | { | 78 | { |
| 76 | asn1_item_combine_free(pval, it, 0); | 79 | asn1_item_combine_free(pval, it, 0); |
| 77 | } | 80 | } |
| 78 | 81 | ||
| 79 | static void asn1_item_combine_free(ASN1_VALUE **pval, const ASN1_ITEM *it, int combine) | 82 | static void |
| 83 | asn1_item_combine_free(ASN1_VALUE **pval, const ASN1_ITEM *it, int combine) | ||
| 80 | { | 84 | { |
| 81 | const ASN1_TEMPLATE *tt = NULL, *seqtt; | 85 | const ASN1_TEMPLATE *tt = NULL, *seqtt; |
| 82 | const ASN1_EXTERN_FUNCS *ef; | 86 | const ASN1_EXTERN_FUNCS *ef; |
| @@ -84,6 +88,7 @@ static void asn1_item_combine_free(ASN1_VALUE **pval, const ASN1_ITEM *it, int c | |||
| 84 | const ASN1_AUX *aux = it->funcs; | 88 | const ASN1_AUX *aux = it->funcs; |
| 85 | ASN1_aux_cb *asn1_cb; | 89 | ASN1_aux_cb *asn1_cb; |
| 86 | int i; | 90 | int i; |
| 91 | |||
| 87 | if (!pval) | 92 | if (!pval) |
| 88 | return; | 93 | return; |
| 89 | if ((it->itype != ASN1_ITYPE_PRIMITIVE) && !*pval) | 94 | if ((it->itype != ASN1_ITYPE_PRIMITIVE) && !*pval) |
| @@ -93,8 +98,7 @@ static void asn1_item_combine_free(ASN1_VALUE **pval, const ASN1_ITEM *it, int c | |||
| 93 | else | 98 | else |
| 94 | asn1_cb = 0; | 99 | asn1_cb = 0; |
| 95 | 100 | ||
| 96 | switch(it->itype) { | 101 | switch (it->itype) { |
| 97 | |||
| 98 | case ASN1_ITYPE_PRIMITIVE: | 102 | case ASN1_ITYPE_PRIMITIVE: |
| 99 | if (it->templates) | 103 | if (it->templates) |
| 100 | ASN1_template_free(pval, it->templates); | 104 | ASN1_template_free(pval, it->templates); |
| @@ -147,10 +151,10 @@ static void asn1_item_combine_free(ASN1_VALUE **pval, const ASN1_ITEM *it, int c | |||
| 147 | i = asn1_cb(ASN1_OP_FREE_PRE, pval, it, NULL); | 151 | i = asn1_cb(ASN1_OP_FREE_PRE, pval, it, NULL); |
| 148 | if (i == 2) | 152 | if (i == 2) |
| 149 | return; | 153 | return; |
| 150 | } | 154 | } |
| 151 | asn1_enc_free(pval, it); | 155 | asn1_enc_free(pval, it); |
| 152 | /* If we free up as normal we will invalidate any | 156 | /* If we free up as normal we will invalidate any |
| 153 | * ANY DEFINED BY field and we wont be able to | 157 | * ANY DEFINED BY field and we wont be able to |
| 154 | * determine the type of the field it defines. So | 158 | * determine the type of the field it defines. So |
| 155 | * free up in reverse order. | 159 | * free up in reverse order. |
| 156 | */ | 160 | */ |
| @@ -173,7 +177,8 @@ static void asn1_item_combine_free(ASN1_VALUE **pval, const ASN1_ITEM *it, int c | |||
| 173 | } | 177 | } |
| 174 | } | 178 | } |
| 175 | 179 | ||
| 176 | void ASN1_template_free(ASN1_VALUE **pval, const ASN1_TEMPLATE *tt) | 180 | void |
| 181 | ASN1_template_free(ASN1_VALUE **pval, const ASN1_TEMPLATE *tt) | ||
| 177 | { | 182 | { |
| 178 | int i; | 183 | int i; |
| 179 | if (tt->flags & ASN1_TFLG_SK_MASK) { | 184 | if (tt->flags & ASN1_TFLG_SK_MASK) { |
| @@ -182,17 +187,17 @@ void ASN1_template_free(ASN1_VALUE **pval, const ASN1_TEMPLATE *tt) | |||
| 182 | ASN1_VALUE *vtmp; | 187 | ASN1_VALUE *vtmp; |
| 183 | vtmp = sk_ASN1_VALUE_value(sk, i); | 188 | vtmp = sk_ASN1_VALUE_value(sk, i); |
| 184 | asn1_item_combine_free(&vtmp, ASN1_ITEM_ptr(tt->item), | 189 | asn1_item_combine_free(&vtmp, ASN1_ITEM_ptr(tt->item), |
| 185 | 0); | 190 | 0); |
| 186 | } | 191 | } |
| 187 | sk_ASN1_VALUE_free(sk); | 192 | sk_ASN1_VALUE_free(sk); |
| 188 | *pval = NULL; | 193 | *pval = NULL; |
| 189 | } | 194 | } else |
| 190 | else | ||
| 191 | asn1_item_combine_free(pval, ASN1_ITEM_ptr(tt->item), | 195 | asn1_item_combine_free(pval, ASN1_ITEM_ptr(tt->item), |
| 192 | tt->flags & ASN1_TFLG_COMBINE); | 196 | tt->flags & ASN1_TFLG_COMBINE); |
| 193 | } | 197 | } |
| 194 | 198 | ||
| 195 | void ASN1_primitive_free(ASN1_VALUE **pval, const ASN1_ITEM *it) | 199 | void |
| 200 | ASN1_primitive_free(ASN1_VALUE **pval, const ASN1_ITEM *it) | ||
| 196 | { | 201 | { |
| 197 | int utype; | 202 | int utype; |
| 198 | if (it) { | 203 | if (it) { |
| @@ -220,7 +225,7 @@ void ASN1_primitive_free(ASN1_VALUE **pval, const ASN1_ITEM *it) | |||
| 220 | return; | 225 | return; |
| 221 | } | 226 | } |
| 222 | 227 | ||
| 223 | switch(utype) { | 228 | switch (utype) { |
| 224 | case V_ASN1_OBJECT: | 229 | case V_ASN1_OBJECT: |
| 225 | ASN1_OBJECT_free((ASN1_OBJECT *)*pval); | 230 | ASN1_OBJECT_free((ASN1_OBJECT *)*pval); |
| 226 | break; | 231 | break; |
