diff --git a/src/mms/iso_mms/asn1c/OCTET_STRING.c b/src/mms/iso_mms/asn1c/OCTET_STRING.c index 0e2ae4f..9c908d3 100644 --- a/src/mms/iso_mms/asn1c/OCTET_STRING.c +++ b/src/mms/iso_mms/asn1c/OCTET_STRING.c @@ -94,7 +94,6 @@ asn_TYPE_descriptor_t asn_DEF_OCTET_STRING = { } else { \ RETURN(RC_FAIL); \ } \ - ASN_DEBUG("Reallocating into %ld", (long)_ns); \ } \ memcpy(st->buf + st->size, bufptr, _bs); \ /* Convenient nul-termination */ \ @@ -187,12 +186,6 @@ OCTET_STRING_decode_ber(asn_codec_ctx_t *opt_codec_ctx, int tlv_constr; OS_type_e type_variant = (OS_type_e)specs->subvariant; - ASN_DEBUG("Decoding %s as %s (frame %ld)", - td->name, - (type_variant == _TT_GENERIC) ? - "OCTET STRING" : "OS-SpecialCase", - (long)size); - /* * Create the string if does not exist. */ @@ -254,12 +247,6 @@ OCTET_STRING_decode_ber(asn_codec_ctx_t *opt_codec_ctx, ssize_t Left = ((!sel||(size_t)sel->left >= size) ?(ssize_t)size:sel->left); - - ASN_DEBUG("%p, s->l=%ld, s->wn=%ld, s->g=%ld\n", sel, - (long)(sel?sel->left:0), - (long)(sel?sel->want_nulls:0), - (long)(sel?sel->got:0) - ); if(sel && sel->left <= 0 && sel->want_nulls == 0) { if(sel->prev) { struct _stack_el *prev = sel->prev; @@ -280,11 +267,7 @@ OCTET_STRING_decode_ber(asn_codec_ctx_t *opt_codec_ctx, } tl = ber_fetch_tag(buf_ptr, Left, &tlv_tag); - ASN_DEBUG("fetch tag(size=%ld,L=%ld), %sstack, left=%ld, wn=%ld, tl=%ld", - (long)size, (long)Left, sel?"":"!", - (long)(sel?sel->left:0), - (long)(sel?sel->want_nulls:0), - (long)tl); + switch(tl) { case -1: RETURN(RC_FAIL); case 0: RETURN(RC_WMORE); @@ -294,9 +277,7 @@ OCTET_STRING_decode_ber(asn_codec_ctx_t *opt_codec_ctx, ll = ber_fetch_length(tlv_constr, (const char *)buf_ptr + tl,Left - tl,&tlv_len); - ASN_DEBUG("Got tag=%s, tc=%d, left=%ld, tl=%ld, len=%ld, ll=%ld", - ber_tlv_tag_string(tlv_tag), tlv_constr, - (long)Left, (long)tl, (long)tlv_len, (long)ll); + switch(ll) { case -1: RETURN(RC_FAIL); case 0: RETURN(RC_WMORE); @@ -307,8 +288,6 @@ OCTET_STRING_decode_ber(asn_codec_ctx_t *opt_codec_ctx, && ((const uint8_t *)buf_ptr)[1] == 0) { - ASN_DEBUG("Eat EOC; wn=%d--", sel->want_nulls); - if(type_variant == _TT_ANY && (tag_mode != 1 || sel->cont_level)) APPEND("\0\0", 2); @@ -359,21 +338,12 @@ OCTET_STRING_decode_ber(asn_codec_ctx_t *opt_codec_ctx, if(tlv_tag != expected_tag) { - char buf[2][32]; - ber_tlv_tag_snprint(tlv_tag, - buf[0], sizeof(buf[0])); - ber_tlv_tag_snprint(td->tags[td->tags_count-1], - buf[1], sizeof(buf[1])); - ASN_DEBUG("Tag does not match expectation: %s != %s", - buf[0], buf[1]); RETURN(RC_FAIL); } tlvl = tl + ll; /* Combined length of T and L encoding */ if((tlv_len + tlvl) < 0) { /* tlv_len value is too big */ - ASN_DEBUG("TLV encoding + length (%ld) is too big", - (long)tlv_len); RETURN(RC_FAIL); } @@ -403,14 +373,9 @@ OCTET_STRING_decode_ber(asn_codec_ctx_t *opt_codec_ctx, sel->got += tlvl; ADVANCE(tlvl); - ASN_DEBUG("+EXPECT2 got=%ld left=%ld, wn=%d, clvl=%d", - (long)sel->got, (long)sel->left, - sel->want_nulls, sel->cont_level); - } while(tlv_constr); if(sel == NULL) { /* Finished operation, "phase out" */ - ASN_DEBUG("Phase out"); _CH_PHASE(ctx, +3); break; } @@ -420,9 +385,7 @@ OCTET_STRING_decode_ber(asn_codec_ctx_t *opt_codec_ctx, case 2: stck = (struct _stack *)ctx->ptr; sel = stck->cur_ptr; - ASN_DEBUG("Phase 2: Need %ld bytes, size=%ld, alrg=%ld, wn=%d", - (long)sel->left, (long)size, (long)sel->got, - sel->want_nulls); + { ber_tlv_len_t len; @@ -446,8 +409,6 @@ OCTET_STRING_decode_ber(asn_codec_ctx_t *opt_codec_ctx, } if(sel->left) { - ASN_DEBUG("OS left %ld, size = %ld, wn=%d\n", - (long)sel->left, (long)size, sel->want_nulls); RETURN(RC_WMORE); } @@ -491,9 +452,6 @@ OCTET_STRING_decode_ber(asn_codec_ctx_t *opt_codec_ctx, } if(sel) { - ASN_DEBUG("3sel p=%p, wn=%d, l=%ld, g=%ld, size=%ld", - sel->prev, sel->want_nulls, - (long)sel->left, (long)sel->got, (long)size); if(sel->prev || sel->want_nulls > 1 || sel->left > 0) { RETURN(RC_WMORE); } @@ -507,12 +465,6 @@ OCTET_STRING_decode_ber(asn_codec_ctx_t *opt_codec_ctx, st->buf[st->size-1] &= 0xff << st->bits_unused; } - ASN_DEBUG("Took %ld bytes to encode %s: [%s]:%ld", - (long)consumed_myself, td->name, - (type_variant == _TT_GENERIC) ? (char *)st->buf : "", - (long)st->size); - - RETURN(RC_OK); } @@ -531,9 +483,6 @@ OCTET_STRING_encode_der(asn_TYPE_descriptor_t *td, void *sptr, OS_type_e type_variant = (OS_type_e)specs->subvariant; int fix_last_byte = 0; - ASN_DEBUG("%s %s as OCTET STRING", - cb?"Estimating":"Encoding", td->name); - /* * Write tags. */ @@ -1274,9 +1223,6 @@ OCTET_STRING_decode_uper(asn_codec_ctx_t *opt_codec_ctx, if(len_bits < 0) RETURN(RC_WMORE); len_bits += ct->lower_bound; - ASN_DEBUG("Got PER length eb %ld, len %ld, %s (%s)", - (long)ct->effective_bits, (long)len_bits, - repeat ? "repeat" : "once", td->name); if(unit_bits == 1) { len_bytes = (len_bits + 7) >> 3; if(len_bits & 0x7) @@ -1323,17 +1269,9 @@ OCTET_STRING_encode_uper(asn_TYPE_descriptor_t *td, _ASN_ENCODE_FAILED; if(unit_bits == 1) { - ASN_DEBUG("BIT STRING of %d bytes, %d bits unused", - sizeinunits, st->bits_unused); sizeinunits = sizeinunits * 8 - (st->bits_unused & 0x07); } - ASN_DEBUG("Encoding %s into %d units of %d bits" - " (%d..%d, effective %d)%s", - td->name, sizeinunits, unit_bits, - ct->lower_bound, ct->upper_bound, - ct->effective_bits, ct_extensible ? " EXT" : ""); - /* Figure out wheter size lies within PER visible consrtaint */ if(ct->effective_bits >= 0) { @@ -1359,9 +1297,6 @@ OCTET_STRING_encode_uper(asn_TYPE_descriptor_t *td, /* X.691, #16.6: short fixed length encoding (up to 2 octets) */ /* X.691, #16.7: long fixed length encoding (up to 64K octets) */ if(ct->effective_bits >= 0) { - ASN_DEBUG("Encoding %d bytes (%ld), length in %d bits", - st->size, sizeinunits - ct->lower_bound, - ct->effective_bits); ret = per_put_few_bits(po, sizeinunits - ct->lower_bound, ct->effective_bits); if(ret) _ASN_ENCODE_FAILED; @@ -1370,8 +1305,6 @@ OCTET_STRING_encode_uper(asn_TYPE_descriptor_t *td, _ASN_ENCODED_OK(er); } - ASN_DEBUG("Encoding %d bytes", st->size); - if(sizeinunits == 0) { if(uper_put_length(po, 0)) _ASN_ENCODE_FAILED; @@ -1383,8 +1316,6 @@ OCTET_STRING_encode_uper(asn_TYPE_descriptor_t *td, ssize_t maySave = uper_put_length(po, sizeinunits); if(maySave < 0) _ASN_ENCODE_FAILED; - ASN_DEBUG("Encoding %d of %d", maySave, sizeinunits); - ret = per_put_many_bits(po, buf, maySave * unit_bits); if(ret) _ASN_ENCODE_FAILED; @@ -1468,8 +1399,6 @@ OCTET_STRING_free(asn_TYPE_descriptor_t *td, void *sptr, int contents_only) { if(!td || !st) return; - ASN_DEBUG("Freeing %s as OCTET STRING", td->name); - if(st->buf) { FREEMEM(st->buf); } diff --git a/src/mms/iso_mms/asn1c/ber_decoder.c b/src/mms/iso_mms/asn1c/ber_decoder.c index 601f66c..de0695a 100644 --- a/src/mms/iso_mms/asn1c/ber_decoder.c +++ b/src/mms/iso_mms/asn1c/ber_decoder.c @@ -108,8 +108,7 @@ ber_check_tags(asn_codec_ctx_t *opt_codec_ctx, tagno = step /* Continuing where left previously */ + (tag_mode==1?-1:0) ; - ASN_DEBUG("ber_check_tags(%s, size=%ld, tm=%d, step=%d, tagno=%d)", - td->name, (long)size, tag_mode, step, tagno); + /* assert(td->tags_count >= 1) May not be the case for CHOICE or ANY */ if(tag_mode == 0 && tagno == td->tags_count) { @@ -130,8 +129,7 @@ ber_check_tags(asn_codec_ctx_t *opt_codec_ctx, case -1: RETURN(RC_FAIL); case 0: RETURN(RC_WMORE); } - ASN_DEBUG("Advancing %ld in ANY case", - (long)(tag_len + len_len)); + ADVANCE(tag_len + len_len); } else { assert(tagno < td->tags_count); /* At least one loop */ @@ -142,11 +140,7 @@ ber_check_tags(asn_codec_ctx_t *opt_codec_ctx, * Fetch and process T from TLV. */ tag_len = ber_fetch_tag(ptr, size, &tlv_tag); - ASN_DEBUG("Fetching tag from {%p,%ld}: " - "len %ld, step %d, tagno %d got %s", - ptr, (long)size, - (long)tag_len, step, tagno, - ber_tlv_tag_string(tlv_tag)); + switch(tag_len) { case -1: RETURN(RC_FAIL); case 0: RETURN(RC_WMORE); @@ -170,12 +164,7 @@ ber_check_tags(asn_codec_ctx_t *opt_codec_ctx, /* * Unexpected tag. Too bad. */ - ASN_DEBUG("Expected: %s, " - "expectation failed (tn=%d, tm=%d)", - ber_tlv_tag_string(td->tags[tagno]), - tagno, tag_mode - ); - RETURN(RC_FAIL); + RETURN(RC_FAIL); } } @@ -188,15 +177,11 @@ ber_check_tags(asn_codec_ctx_t *opt_codec_ctx, */ if(tagno < (td->tags_count - 1)) { if(tlv_constr == 0) { - ASN_DEBUG("tlv_constr = %d, expfail", - tlv_constr); RETURN(RC_FAIL); } } else { if(last_tag_form != tlv_constr && last_tag_form != -1) { - ASN_DEBUG("last_tag_form %d != %d", - last_tag_form, tlv_constr); RETURN(RC_FAIL); } } @@ -206,7 +191,7 @@ ber_check_tags(asn_codec_ctx_t *opt_codec_ctx, */ len_len = ber_fetch_length(tlv_constr, (const char *)ptr + tag_len, size - tag_len, &tlv_len); - ASN_DEBUG("Fetchinig len = %ld", (long)len_len); + switch(len_len) { case -1: RETURN(RC_FAIL); case 0: RETURN(RC_WMORE); @@ -226,16 +211,12 @@ ber_check_tags(asn_codec_ctx_t *opt_codec_ctx, if(limit_len == -1) { expect_00_terminators++; } else { - ASN_DEBUG("Unexpected indefinite length " - "in a chain of definite lengths"); RETURN(RC_FAIL); } ADVANCE(tag_len + len_len); continue; } else { if(expect_00_terminators) { - ASN_DEBUG("Unexpected definite length " - "in a chain of indefinite lengths"); RETURN(RC_FAIL); } } @@ -255,8 +236,7 @@ ber_check_tags(asn_codec_ctx_t *opt_codec_ctx, * Inner TLV specifies length which is inconsistent * with the outer TLV's length value. */ - ASN_DEBUG("Outer TLV is %ld and inner is %ld", - (long)limit_len, (long)tlv_len); + RETURN(RC_FAIL); } diff --git a/src/mms/iso_mms/asn1c/ber_tlv_tag.c b/src/mms/iso_mms/asn1c/ber_tlv_tag.c index 588d9ee..24588f9 100644 --- a/src/mms/iso_mms/asn1c/ber_tlv_tag.c +++ b/src/mms/iso_mms/asn1c/ber_tlv_tag.c @@ -56,50 +56,6 @@ ber_fetch_tag(const void *ptr, size_t size, ber_tlv_tag_t *tag_r) { return 0; /* Want more */ } - - -ssize_t -ber_tlv_tag_fwrite(ber_tlv_tag_t tag, FILE *f) { - char buf[sizeof("[APPLICATION ]") + 32]; - ssize_t ret; - - ret = ber_tlv_tag_snprint(tag, buf, sizeof(buf)); - if(ret >= (ssize_t)sizeof(buf) || ret < 2) { - errno = EPERM; - return -1; - } - - return fwrite(buf, 1, ret, f); -} - -ssize_t -ber_tlv_tag_snprint(ber_tlv_tag_t tag, char *buf, size_t size) { - char *type = 0; - int ret; - - switch(tag & 0x3) { - case ASN_TAG_CLASS_UNIVERSAL: type = "UNIVERSAL "; break; - case ASN_TAG_CLASS_APPLICATION: type = "APPLICATION "; break; - case ASN_TAG_CLASS_CONTEXT: type = ""; break; - case ASN_TAG_CLASS_PRIVATE: type = "PRIVATE "; break; - } - - ret = snprintf(buf, size, "[%s%u](%02x)", type, ((unsigned)tag) >> 2, tag); - if(ret <= 0 && size) buf[0] = '\0'; /* against broken libc's */ - - return ret; -} - -char * -ber_tlv_tag_string(ber_tlv_tag_t tag) { - static char buf[sizeof("[APPLICATION ]") + 32]; - - (void)ber_tlv_tag_snprint(tag, buf, sizeof(buf)); - - return buf; -} - - size_t ber_tlv_tag_serialize(ber_tlv_tag_t tag, void *bufp, size_t size) { int tclass = BER_TAG_CLASS(tag); diff --git a/src/mms/iso_mms/asn1c/constr_CHOICE.c b/src/mms/iso_mms/asn1c/constr_CHOICE.c index b8d6fa9..de2cc3a 100644 --- a/src/mms/iso_mms/asn1c/constr_CHOICE.c +++ b/src/mms/iso_mms/asn1c/constr_CHOICE.c @@ -117,8 +117,6 @@ CHOICE_decode_ber(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, ssize_t consumed_myself = 0; /* Consumed bytes from ptr */ - ASN_DEBUG("Decoding %s as CHOICE", td->name); - /* * Create the target structure if it is not present already. */ @@ -149,8 +147,6 @@ CHOICE_decode_ber(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, rval = ber_check_tags(opt_codec_ctx, td, ctx, ptr, size, tag_mode, -1, &ctx->left, 0); if(rval.code != RC_OK) { - ASN_DEBUG("%s tagging check failed: %d", - td->name, rval.code); return rval; } @@ -165,16 +161,13 @@ CHOICE_decode_ber(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, NEXT_PHASE(ctx); - ASN_DEBUG("Structure consumes %ld bytes, buffer %ld", - (long)ctx->left, (long)size); - /* Fall through */ case 1: /* * Fetch the T from TLV. */ tag_len = ber_fetch_tag(ptr, LEFT, &tlv_tag); - ASN_DEBUG("In %s CHOICE tag length %d", td->name, (int)tag_len); + switch(tag_len) { case 0: if(!SIZE_VIOLATION) RETURN(RC_WMORE); /* Fall through */ @@ -197,17 +190,11 @@ CHOICE_decode_ber(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, ctx->step = t2m->el_no; break; } else if(specs->ext_start == -1) { - ASN_DEBUG("Unexpected tag %s " - "in non-extensible CHOICE %s", - ber_tlv_tag_string(tlv_tag), td->name); RETURN(RC_FAIL); } else { /* Skip this tag */ ssize_t skip; - ASN_DEBUG("Skipping unknown tag %s", - ber_tlv_tag_string(tlv_tag)); - skip = ber_skip_length(opt_codec_ctx, BER_TLV_CONSTRUCTED(ptr), (const char *)ptr + tag_len, @@ -280,9 +267,6 @@ CHOICE_decode_ber(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, /* Fall through */ case 3: - ASN_DEBUG("CHOICE %s Leftover: %ld, size = %ld, tm=%d, tc=%d", - td->name, (long)ctx->left, (long)size, - tag_mode, td->tags_count); if(ctx->left > 0) { /* @@ -335,8 +319,6 @@ CHOICE_decode_ber(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, continue; } } else { - ASN_DEBUG("Unexpected continuation in %s", - td->name); RETURN(RC_FAIL); } @@ -365,9 +347,6 @@ CHOICE_encode_der(asn_TYPE_descriptor_t *td, void *sptr, if(!sptr) _ASN_ENCODE_FAILED; - ASN_DEBUG("%s %s as CHOICE", - cb?"Encoding":"Estimating", td->name); - present = _fetch_present_idx(sptr, specs->pres_offset, specs->pres_size); @@ -435,9 +414,6 @@ CHOICE_encode_der(asn_TYPE_descriptor_t *td, void *sptr, if(erval.encoded == -1) return erval; - ASN_DEBUG("Encoded CHOICE member in %ld bytes (+%ld)", - (long)erval.encoded, (long)computed_size); - erval.encoded += computed_size; return erval; @@ -482,9 +458,6 @@ CHOICE_constraint(asn_TYPE_descriptor_t *td, const void *sptr, int present; if(!sptr) { - _ASN_CTFAIL(app_key, td, - "%s: value not given (%s:%d)", - td->name, __FILE__, __LINE__); return -1; } @@ -501,9 +474,7 @@ CHOICE_constraint(asn_TYPE_descriptor_t *td, const void *sptr, if(!memb_ptr) { if(elm->optional) return 0; - _ASN_CTFAIL(app_key, td, - "%s: mandatory CHOICE element %s absent (%s:%d)", - td->name, elm->name, __FILE__, __LINE__); + return -1; } } else { @@ -524,9 +495,6 @@ CHOICE_constraint(asn_TYPE_descriptor_t *td, const void *sptr, return ret; } } else { - _ASN_CTFAIL(app_key, td, - "%s: no CHOICE element given (%s:%d)", - td->name, __FILE__, __LINE__); return -1; } } @@ -616,8 +584,7 @@ CHOICE_decode_xer(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, elm->type, memb_ptr2, elm->name, buf_ptr, size); XER_ADVANCE(tmprval.consumed); - ASN_DEBUG("XER/CHOICE: itdf: [%s] code=%d", - elm->type->name, tmprval.code); + if(tmprval.code != RC_OK) RETURN(tmprval.code); assert(_fetch_present_idx(st, @@ -654,17 +621,10 @@ CHOICE_decode_xer(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, } tcv = xer_check_tag(buf_ptr, ch_size, xml_tag); - ASN_DEBUG("XER/CHOICE checked [%c%c%c%c] vs [%s], tcv=%d", - ch_size>0?((const uint8_t *)buf_ptr)[0]:'?', - ch_size>1?((const uint8_t *)buf_ptr)[1]:'?', - ch_size>2?((const uint8_t *)buf_ptr)[2]:'?', - ch_size>3?((const uint8_t *)buf_ptr)[3]:'?', - xml_tag, tcv); /* Skip the extensions section */ if(ctx->phase == 4) { - ASN_DEBUG("skip_unknown(%d, %ld)", - tcv, (long)ctx->left); + switch(xer_skip_unknown(tcv, &ctx->left)) { case -1: ctx->phase = 5; @@ -733,7 +693,6 @@ CHOICE_decode_xer(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, /* It is expected extension */ if(specs->ext_start != -1) { - ASN_DEBUG("Got anticipated extension"); /* * Check for (XCT_BOTH or XCT_UNKNOWN_BO) * By using a mask. Only record a pure @@ -755,13 +714,6 @@ CHOICE_decode_xer(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, break; } - ASN_DEBUG("Unexpected XML tag [%c%c%c%c] in CHOICE [%s]" - " (ph=%d, tag=%s)", - ch_size>0?((const uint8_t *)buf_ptr)[0]:'?', - ch_size>1?((const uint8_t *)buf_ptr)[1]:'?', - ch_size>2?((const uint8_t *)buf_ptr)[2]:'?', - ch_size>3?((const uint8_t *)buf_ptr)[3]:'?', - td->name, ctx->phase, xml_tag); break; } @@ -859,8 +811,7 @@ CHOICE_decode_uper(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, if(ct && ct->range_bits >= 0) { value = per_get_few_bits(pd, ct->range_bits); if(value < 0) _ASN_DECODE_STARVED; - ASN_DEBUG("CHOICE %s got index %d in range %d", - td->name, value, ct->range_bits); + if(value > ct->upper_bound) _ASN_DECODE_FAILED; } else { @@ -871,7 +822,7 @@ CHOICE_decode_uper(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, value += specs->ext_start; if(value >= td->elements_count) _ASN_DECODE_FAILED; - ASN_DEBUG("NOT IMPLEMENTED YET"); + _ASN_DECODE_FAILED; } @@ -890,13 +841,10 @@ CHOICE_decode_uper(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, memb_ptr = (char *)st + elm->memb_offset; memb_ptr2 = &memb_ptr; } - ASN_DEBUG("Discovered CHOICE %s encodes %s", td->name, elm->name); rv = elm->type->uper_decoder(opt_codec_ctx, elm->type, elm->per_constraints, memb_ptr2, pd); - if(rv.code != RC_OK) - ASN_DEBUG("Failed to decode %s in %s (CHOICE)", - elm->name, td->name); + return rv; } @@ -911,8 +859,6 @@ CHOICE_encode_uper(asn_TYPE_descriptor_t *td, if(!sptr) _ASN_ENCODE_FAILED; - ASN_DEBUG("Encoding %s as CHOICE", td->name); - if(constraints) ct = &constraints->value; else if(td->per_constraints) ct = &td->per_constraints->value; else ct = 0; @@ -933,8 +879,6 @@ CHOICE_encode_uper(asn_TYPE_descriptor_t *td, if(specs->canonical_order) present = specs->canonical_order[present]; - ASN_DEBUG("Encoding %s CHOICE element %d", td->name, present); - if(ct && ct->range_bits >= 0) { if(present < ct->lower_bound || present > ct->upper_bound) { @@ -959,7 +903,7 @@ CHOICE_encode_uper(asn_TYPE_descriptor_t *td, _ASN_ENCODE_FAILED; if(uper_put_nsnnwn(po, present - specs->ext_start)) _ASN_ENCODE_FAILED; - ASN_DEBUG("NOT IMPLEMENTED YET"); + _ASN_ENCODE_FAILED; } @@ -1026,8 +970,6 @@ CHOICE_free(asn_TYPE_descriptor_t *td, void *ptr, int contents_only) { if(!td || !ptr) return; - ASN_DEBUG("Freeing %s as CHOICE", td->name); - /* * Figure out which CHOICE element is encoded. */ diff --git a/src/mms/iso_mms/asn1c/constr_SEQUENCE.c b/src/mms/iso_mms/asn1c/constr_SEQUENCE.c index b769434..72043f5 100644 --- a/src/mms/iso_mms/asn1c/constr_SEQUENCE.c +++ b/src/mms/iso_mms/asn1c/constr_SEQUENCE.c @@ -127,8 +127,6 @@ SEQUENCE_decode_ber(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, ssize_t consumed_myself = 0; /* Consumed bytes from ptr */ int edx; /* SEQUENCE element's index */ - - ASN_DEBUG("Decoding %s as SEQUENCE", td->name); /* * Create the target structure if it is not present already. @@ -159,8 +157,6 @@ SEQUENCE_decode_ber(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, rval = ber_check_tags(opt_codec_ctx, td, ctx, ptr, size, tag_mode, 1, &ctx->left, 0); if(rval.code != RC_OK) { - ASN_DEBUG("%s tagging check failed: %d", - td->name, rval.code); return rval; } @@ -170,9 +166,6 @@ SEQUENCE_decode_ber(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, NEXT_PHASE(ctx); - ASN_DEBUG("Structure consumes %ld bytes, buffer %ld", - (long)ctx->left, (long)size); - /* Fall through */ case 1: /* @@ -200,11 +193,6 @@ SEQUENCE_decode_ber(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, /* * MICROPHASE 1: Synchronize decoding. */ - ASN_DEBUG("In %s SEQUENCE left %d, edx=%d flags=%d" - " opt=%d ec=%d", - td->name, (int)ctx->left, edx, - elements[edx].flags, elements[edx].optional, - td->elements_count); if(ctx->left == 0 /* No more stuff is expected */ && ( @@ -217,7 +205,6 @@ SEQUENCE_decode_ber(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, && specs->ext_before > td->elements_count) ) ) { - ASN_DEBUG("End of SEQUENCE %s", td->name); /* * Found the legitimate end of the structure. */ @@ -229,10 +216,7 @@ SEQUENCE_decode_ber(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, * Fetch the T from TLV. */ tag_len = ber_fetch_tag(ptr, LEFT, &tlv_tag); - ASN_DEBUG("Current tag in %s SEQUENCE for element %d " - "(%s) is %s encoded in %d bytes, of frame %ld", - td->name, edx, elements[edx].name, - ber_tlv_tag_string(tlv_tag), (int)tag_len, (long)LEFT); + switch(tag_len) { case 0: if(!SIZE_VIOLATION) RETURN(RC_WMORE); /* Fall through */ @@ -246,9 +230,7 @@ SEQUENCE_decode_ber(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, else RETURN(RC_WMORE); } else if(((const uint8_t *)ptr)[1] == 0) { - ASN_DEBUG("edx = %d, opt = %d, ec=%d", - edx, elements[edx].optional, - td->elements_count); + if((edx + elements[edx].optional == td->elements_count) || (IN_EXTENSION_GROUP(specs, edx) @@ -347,13 +329,6 @@ SEQUENCE_decode_ber(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, * or an end of the indefinite-length structure. */ if(!IN_EXTENSION_GROUP(specs, edx)) { - ASN_DEBUG("Unexpected tag %s (at %d)", - ber_tlv_tag_string(tlv_tag), edx); - ASN_DEBUG("Expected tag %s (%s)%s", - ber_tlv_tag_string(elements[edx].tag), - elements[edx].name, - elements[edx].optional - ?" or alternatives":""); RETURN(RC_FAIL); } else { /* Skip this tag */ @@ -363,8 +338,7 @@ SEQUENCE_decode_ber(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, BER_TLV_CONSTRUCTED(ptr), (const char *)ptr + tag_len, LEFT - tag_len); - ASN_DEBUG("Skip length %d in %s", - (int)skip, td->name); + switch(skip) { case 0: if(!SIZE_VIOLATION) RETURN(RC_WMORE); /* Fall through */ @@ -383,7 +357,6 @@ SEQUENCE_decode_ber(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, */ ctx->step |= 1; /* Confirm entering next microphase */ microphase2: - ASN_DEBUG("Inside SEQUENCE %s MF2", td->name); /* * Compute the position of the member inside a structure, @@ -408,10 +381,7 @@ SEQUENCE_decode_ber(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, elements[edx].type, memb_ptr2, ptr, LEFT, elements[edx].tag_mode); - ASN_DEBUG("In %s SEQUENCE decoded %d %s of %d " - "in %d bytes rval.code %d, size=%d", - td->name, edx, elements[edx].type->name, - (int)LEFT, (int)rval.consumed, rval.code, (int)size); + switch(rval.code) { case RC_OK: break; @@ -420,8 +390,7 @@ SEQUENCE_decode_ber(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, ADVANCE(rval.consumed); RETURN(RC_WMORE); } - ASN_DEBUG("Size violation (c->l=%ld <= s=%ld)", - (long)ctx->left, (long)size); + /* Fall through */ case RC_FAIL: /* Fatal error */ RETURN(RC_FAIL); @@ -435,9 +404,6 @@ SEQUENCE_decode_ber(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, case 3: /* 00 and other tags expected */ case 4: /* only 00's expected */ - ASN_DEBUG("SEQUENCE %s Leftover: %ld, size = %ld", - td->name, (long)ctx->left, (long)size); - /* * Skip everything until the end of the SEQUENCE. */ @@ -474,11 +440,6 @@ SEQUENCE_decode_ber(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, if(!IN_EXTENSION_GROUP(specs, td->elements_count) || ctx->phase == 4) { - ASN_DEBUG("Unexpected continuation " - "of a non-extensible type " - "%s (SEQUENCE): %s", - td->name, - ber_tlv_tag_string(tlv_tag)); RETURN(RC_FAIL); } diff --git a/src/mms/iso_mms/asn1c/constr_SET_OF.c b/src/mms/iso_mms/asn1c/constr_SET_OF.c index c4928e2..7e9e3f6 100644 --- a/src/mms/iso_mms/asn1c/constr_SET_OF.c +++ b/src/mms/iso_mms/asn1c/constr_SET_OF.c @@ -84,8 +84,6 @@ SET_OF_decode_ber(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, asn_dec_rval_t rval; /* Return code from subparsers */ ssize_t consumed_myself = 0; /* Consumed bytes from ptr */ - - ASN_DEBUG("Decoding %s as SET OF", td->name); /* * Create the target structure if it is not present already. @@ -116,8 +114,6 @@ SET_OF_decode_ber(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, rval = ber_check_tags(opt_codec_ctx, td, ctx, ptr, size, tag_mode, 1, &ctx->left, 0); if(rval.code != RC_OK) { - ASN_DEBUG("%s tagging check failed: %d", - td->name, rval.code); return rval; } @@ -125,9 +121,6 @@ SET_OF_decode_ber(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, ctx->left += rval.consumed; /* ?Substracted below! */ ADVANCE(rval.consumed); - ASN_DEBUG("Structure consumes %ld bytes, " - "buffer %ld", (long)ctx->left, (long)size); - NEXT_PHASE(ctx); /* Fall through */ case 1: @@ -147,7 +140,6 @@ SET_OF_decode_ber(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, */ if(ctx->left == 0) { - ASN_DEBUG("End of SET OF %s", td->name); /* * No more things to decode. * Exit out of here. @@ -188,10 +180,6 @@ SET_OF_decode_ber(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, * The new list member of expected type has arrived. */ } else { - ASN_DEBUG("Unexpected tag %s fixed SET OF %s", - ber_tlv_tag_string(tlv_tag), td->name); - ASN_DEBUG("%s SET OF has tag %s", - td->name, ber_tlv_tag_string(elm->tag)); RETURN(RC_FAIL); } } @@ -207,9 +195,7 @@ SET_OF_decode_ber(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, */ rval = elm->type->ber_decoder(opt_codec_ctx, elm->type, &ctx->ptr, ptr, LEFT, 0); - ASN_DEBUG("In %s SET OF %s code %d consumed %d", - td->name, elm->type->name, - rval.code, (int)rval.consumed); + switch(rval.code) { case RC_OK: { @@ -324,8 +310,6 @@ SET_OF_encode_der(asn_TYPE_descriptor_t *td, void *ptr, int ret; int edx; - ASN_DEBUG("Estimating size for SET OF %s", td->name); - /* * Gather the length of the underlying members sequence. */ @@ -374,8 +358,6 @@ SET_OF_encode_der(asn_TYPE_descriptor_t *td, void *ptr, return erval; } - ASN_DEBUG("Encoding members of %s SET OF", td->name); - /* * Encode all members. */ @@ -523,7 +505,6 @@ SET_OF_decode_xer(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, asn_dec_rval_t tmprval; /* Invoke the inner type decoder, m.b. multiple times */ - ASN_DEBUG("XER/SET OF element [%s]", elm_tag); tmprval = element->type->xer_decoder(opt_codec_ctx, element->type, &ctx->ptr, elm_tag, buf_ptr, size); @@ -538,7 +519,6 @@ SET_OF_decode_xer(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, RETURN(tmprval.code); } ctx->phase = 1; /* Back to body processing */ - ASN_DEBUG("XER/SET OF phase => %d", ctx->phase); /* Fall through */ } @@ -562,8 +542,7 @@ SET_OF_decode_xer(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, } tcv = xer_check_tag(buf_ptr, ch_size, xml_tag); - ASN_DEBUG("XER/SET OF: tcv = %d, ph=%d t=%s", - tcv, ctx->phase, xml_tag); + switch(tcv) { case XCT_CLOSING: if(ctx->phase == 0) break; @@ -587,7 +566,6 @@ SET_OF_decode_xer(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, case XCT_UNKNOWN_OP: case XCT_UNKNOWN_BO: - ASN_DEBUG("XER/SET OF: tcv=%d, ph=%d", tcv, ctx->phase); if(ctx->phase == 1) { /* * Process a single possible member. @@ -600,7 +578,6 @@ SET_OF_decode_xer(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, break; } - ASN_DEBUG("Unexpected XML tag in SET OF"); break; } @@ -819,9 +796,6 @@ SET_OF_constraint(asn_TYPE_descriptor_t *td, const void *sptr, int i; if(!sptr) { - _ASN_CTFAIL(app_key, td, - "%s: value not given (%s:%d)", - td->name, __FILE__, __LINE__); return -1; } @@ -890,8 +864,7 @@ SET_OF_decode_uper(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, if(ct && ct->effective_bits >= 0) { /* X.691, #19.5: No length determinant */ nelems = per_get_few_bits(pd, ct->effective_bits); - ASN_DEBUG("Preparing to fetch %ld+%ld elements from %s", - (long)nelems, ct->lower_bound, td->name); + if(nelems < 0) _ASN_DECODE_STARVED; nelems += ct->lower_bound; } else { @@ -908,20 +881,11 @@ SET_OF_decode_uper(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, for(i = 0; i < nelems; i++) { void *ptr = 0; - ASN_DEBUG("SET OF %s decoding", elm->type->name); - rv = elm->type->uper_decoder(opt_codec_ctx, elm->type, - elm->per_constraints, &ptr, pd); - ASN_DEBUG("%s SET OF %s decoded %d, %p", - td->name, elm->type->name, rv.code, ptr); + if(rv.code == RC_OK) { if(ASN_SET_ADD(list, ptr) == 0) continue; - ASN_DEBUG("Failed to add element into %s", - td->name); /* Fall through */ - } else { - ASN_DEBUG("Failed decoding %s of %s (SET OF)", - elm->type->name, td->name); } if(ptr) ASN_STRUCT_FREE(*elm->type, ptr); return rv; @@ -930,8 +894,6 @@ SET_OF_decode_uper(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, nelems = -1; /* Allow uper_get_length() */ } while(repeat); - ASN_DEBUG("Decoded %s as SET OF", td->name); - rv.code = RC_OK; rv.consumed = 0; return rv;