summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNikos Mavrogiannopoulos <nmav@redhat.com>2014-08-20 09:49:22 +0200
committerNikos Mavrogiannopoulos <nmav@redhat.com>2014-08-20 09:55:13 +0200
commit1519e2daff51ecb9824adbd815e7e11f7b2988d3 (patch)
treeedca73ad513da0a8f6c41dd4090344521fbea043
parentd13728f319fe74101df57dfabe16907c5d517d28 (diff)
downloadlibtasn1-1519e2daff51ecb9824adbd815e7e11f7b2988d3.tar.gz
BER decoding: corrected indefinite tag check in ANY constructions
-rw-r--r--lib/decoding.c46
1 files changed, 24 insertions, 22 deletions
diff --git a/lib/decoding.c b/lib/decoding.c
index 64cc290..e7bd19f 100644
--- a/lib/decoding.c
+++ b/lib/decoding.c
@@ -1358,6 +1358,12 @@ asn1_der_decoding (asn1_node * element, const void *ider, int ider_len,
move = RIGHT;
break;
case ASN1_ETYPE_ANY:
+ /* Check indefinite lenth method in an EXPLICIT TAG */
+ if ((p->type & CONST_TAG) && (der[counter - 1] == 0x80))
+ indefinite = 1;
+ else
+ indefinite = 0;
+
if (asn1_get_tag_der
(der + counter, ider_len, &class, &len2,
&tag) != ASN1_SUCCESS)
@@ -1397,12 +1403,6 @@ asn1_der_decoding (asn1_node * element, const void *ider, int ider_len,
goto cleanup;
}
- /* Check indefinite lenth method in an EXPLICIT TAG */
- if ((p->type & CONST_TAG) && (der[counter - 1] == 0x80))
- indefinite = 1;
- else
- indefinite = 0;
-
result =
_asn1_get_indefinite_length_string (der + counter, ider_len, &len2);
if (result != ASN1_SUCCESS)
@@ -1415,23 +1415,25 @@ asn1_der_decoding (asn1_node * element, const void *ider, int ider_len,
_asn1_set_value_lv (p, der + counter, len2);
counter += len2;
- /* Check if a couple of 0x00 are present due to an EXPLICIT TAG with
- an indefinite length method. */
- if (indefinite)
- {
- DECR_LEN(ider_len, 2);
- if (!der[counter] && !der[counter + 1])
- {
- counter += 2;
- }
- else
- {
- result = ASN1_DER_ERROR;
- warn();
- goto cleanup;
- }
- }
}
+
+ /* Check if a couple of 0x00 are present due to an EXPLICIT TAG with
+ an indefinite length method. */
+ if (indefinite)
+ {
+ DECR_LEN(ider_len, 2);
+ if (!der[counter] && !der[counter + 1])
+ {
+ counter += 2;
+ }
+ else
+ {
+ result = ASN1_DER_ERROR;
+ warn();
+ goto cleanup;
+ }
+ }
+
move = RIGHT;
break;
default: