зеркало из https://github.com/mozilla/pjs.git
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.
This commit is contained in:
Родитель
435d518222
Коммит
2e712568df
|
@ -35,7 +35,7 @@
|
|||
* Support for DEcoding ASN.1 data based on BER/DER (Basic/Distinguished
|
||||
* Encoding Rules).
|
||||
*
|
||||
* $Id: secasn1d.c,v 1.3 2000-06-13 21:56:36 chrisk%netscape.com Exp $
|
||||
* $Id: secasn1d.c,v 1.4 2000-06-20 13:24:01 chrisk%netscape.com Exp $
|
||||
*/
|
||||
|
||||
#include "secasn1.h"
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
Загрузка…
Ссылка в новой задаче