summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorchrisk%netscape.com <devnull@localhost>2000-06-20 13:24:01 +0000
committerchrisk%netscape.com <devnull@localhost>2000-06-20 13:24:01 +0000
commita47cdee6ab0a84cae5901504d87279b8d43088d4 (patch)
tree6e0e9335ea79c15545fb145a749ab88c612275a4
parentb9b2c0600fcf6bb947729c2fca8958fb345b0e66 (diff)
downloadnss-hg-a47cdee6ab0a84cae5901504d87279b8d43088d4.tar.gz
Fix bug in decoder:
When encoding indefinitely & encountering an optional field at the end of a sequence, right after an IMPLICIT or POINTER template, the decoder was not propagating the optionalness and the end-of-contents condition correctly as it hits the end-of-contents octets instead of the optional field. This is because IMPLICIT and POINTER push TWO states to look for the next tag, not just one. (The first state is "afterImplicit" or "afterPointer", the second one starts with "beforeIdentifier" as usual). This finally makes decoding envelopedData messages in cmsutil work.
-rw-r--r--security/nss/lib/util/secasn1d.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/security/nss/lib/util/secasn1d.c b/security/nss/lib/util/secasn1d.c
index d1f9fd642..544210d3d 100644
--- a/security/nss/lib/util/secasn1d.c
+++ b/security/nss/lib/util/secasn1d.c
@@ -628,8 +628,15 @@ sec_asn1d_parse_identifier (sec_asn1d_state *state,
*/
state->pending = 1;
} else {
- if (byte == 0 && state->parent != NULL
- && state->parent->indefinite) {
+ if (byte == 0 && state->parent != NULL &&
+ (state->parent->indefinite ||
+ (
+ (state->parent->place == afterImplicit ||
+ state->parent->place == afterPointer)
+ && state->parent->parent != NULL && state->parent->parent->indefinite
+ )
+ )
+ ) {
/*
* Our parent has indefinite-length encoding, and the
* entire tag found is 0, so it seems that we have hit the
@@ -1730,7 +1737,7 @@ sec_asn1d_next_in_sequence (sec_asn1d_state *state)
*/
sec_asn1d_notify_before (state->top, child->dest, child->depth);
- if (child_missing) {
+ if (child_missing) { /* if previous child was missing, copy the tag data we already have */
child_found_tag_modifiers = child->found_tag_modifiers;
child_found_tag_number = child->found_tag_number;
}
@@ -1928,6 +1935,7 @@ sec_asn1d_absorb_child (sec_asn1d_state *state)
|| state->place == afterPointer);
state->found_tag_number = state->child->found_tag_number;
state->found_tag_modifiers = state->child->found_tag_modifiers;
+ state->endofcontents = state->child->endofcontents;
}
/*