X-Git-Url: https://git.stg.codes/stg.git/blobdiff_plain/46b0747592074017ff0ea4b33d4a7194235886e5..2574a28cbf000603bc31f61593dbf061ff56c1d5:/libs/smux/ber_decoder.c diff --git a/libs/smux/ber_decoder.c b/libs/smux/ber_decoder.c index 601f66c0..75d60169 100644 --- a/libs/smux/ber_decoder.c +++ b/libs/smux/ber_decoder.c @@ -27,10 +27,10 @@ * The BER decoder of any type. */ asn_dec_rval_t -ber_decode(asn_codec_ctx_t *opt_codec_ctx, - asn_TYPE_descriptor_t *type_descriptor, - void **struct_ptr, const void *ptr, size_t size) { - asn_codec_ctx_t s_codec_ctx; +ber_decode(const asn_codec_ctx_t *opt_codec_ctx, + const asn_TYPE_descriptor_t *type_descriptor, void **struct_ptr, + const void *ptr, size_t size) { + asn_codec_ctx_t s_codec_ctx; /* * Stack checker requires that the codec context @@ -44,14 +44,14 @@ ber_decode(asn_codec_ctx_t *opt_codec_ctx, } else { /* If context is not given, be security-conscious anyway */ memset(&s_codec_ctx, 0, sizeof(s_codec_ctx)); - s_codec_ctx.max_stack_size = _ASN_DEFAULT_STACK_MAX; + s_codec_ctx.max_stack_size = ASN__DEFAULT_STACK_MAX; opt_codec_ctx = &s_codec_ctx; } /* * Invoke type-specific decoder. */ - return type_descriptor->ber_decoder(opt_codec_ctx, type_descriptor, + return type_descriptor->op->ber_decoder(opt_codec_ctx, type_descriptor, struct_ptr, /* Pointer to the destination structure */ ptr, size, /* Buffer and its size */ 0 /* Default tag mode is 0 */ @@ -62,11 +62,11 @@ ber_decode(asn_codec_ctx_t *opt_codec_ctx, * Check the set of >> tags matches the definition. */ asn_dec_rval_t -ber_check_tags(asn_codec_ctx_t *opt_codec_ctx, - asn_TYPE_descriptor_t *td, asn_struct_ctx_t *opt_ctx, - const void *ptr, size_t size, int tag_mode, int last_tag_form, - ber_tlv_len_t *last_length, int *opt_tlv_form) { - ssize_t consumed_myself = 0; +ber_check_tags(const asn_codec_ctx_t *opt_codec_ctx, + const asn_TYPE_descriptor_t *td, asn_struct_ctx_t *opt_ctx, + const void *ptr, size_t size, int tag_mode, int last_tag_form, + ber_tlv_len_t *last_length, int *opt_tlv_form) { + ssize_t consumed_myself = 0; ssize_t tag_len; ssize_t len_len; ber_tlv_tag_t tlv_tag; @@ -80,7 +80,7 @@ ber_check_tags(asn_codec_ctx_t *opt_codec_ctx, /* * Make sure we didn't exceed the maximum stack size. */ - if(_ASN_STACK_OVERFLOW_CHECK(opt_codec_ctx)) + if(ASN__STACK_OVERFLOW_CHECK(opt_codec_ctx)) RETURN(RC_FAIL); /* @@ -112,7 +112,7 @@ ber_check_tags(asn_codec_ctx_t *opt_codec_ctx, 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) { + if(tag_mode == 0 && tagno == (int)td->tags_count) { /* * This must be the _untagged_ ANY type, * which outermost tag isn't known in advance. @@ -134,9 +134,9 @@ ber_check_tags(asn_codec_ctx_t *opt_codec_ctx, (long)(tag_len + len_len)); ADVANCE(tag_len + len_len); } else { - assert(tagno < td->tags_count); /* At least one loop */ + assert(tagno < (int)td->tags_count); /* At least one loop */ } - for((void)tagno; tagno < td->tags_count; tagno++, step++) { + for((void)tagno; tagno < (int)td->tags_count; tagno++, step++) { /* * Fetch and process T from TLV. @@ -186,7 +186,7 @@ ber_check_tags(asn_codec_ctx_t *opt_codec_ctx, * If this one is the last one, check that the tag form * matches the one given in descriptor. */ - if(tagno < (td->tags_count - 1)) { + if(tagno < ((int)td->tags_count - 1)) { if(tlv_constr == 0) { ASN_DEBUG("tlv_constr = %d, expfail", tlv_constr); @@ -206,7 +206,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); + ASN_DEBUG("Fetching len = %ld", (long)len_len); switch(len_len) { case -1: RETURN(RC_FAIL); case 0: RETURN(RC_WMORE);