Commit 00918813 authored by Lev Walkin's avatar Lev Walkin

debugging

parent efbba4ab
...@@ -57,8 +57,8 @@ cat Makefile.am.sample \ ...@@ -57,8 +57,8 @@ cat Makefile.am.sample \
echo " $0" echo " $0"
echo echo
echo 'check: ${TARGET}' echo 'check: ${TARGET}'
echo " @if test -f ./sample-${ASN1PDU}-1.[db]er ; then \\" echo " @if test -f sample-${ASN1PDU}-1.[db]er ; then \\"
echo " for f in ./sample-${ASN1PDU}-*.[db]er; do \\" echo " for f in sample-${ASN1PDU}-*.[db]er; do \\"
echo ' echo "Recoding $$f into XER and back..."; \' echo ' echo "Recoding $$f into XER and back..."; \'
echo ' ./${TARGET} -iber -oxer -b 1 $$f > ./.tmp.1.$$$$ || exit 2; \' echo ' ./${TARGET} -iber -oxer -b 1 $$f > ./.tmp.1.$$$$ || exit 2; \'
echo ' ./${TARGET} -iber -oxer -b 17 $$f > ./.tmp.1.$$$$ || exit 2; \' echo ' ./${TARGET} -iber -oxer -b 17 $$f > ./.tmp.1.$$$$ || exit 2; \'
...@@ -69,8 +69,8 @@ cat Makefile.am.sample \ ...@@ -69,8 +69,8 @@ cat Makefile.am.sample \
echo ' diff ./.tmp.1.$$$$ ./.tmp.2.$$$$ || exit 2; \' echo ' diff ./.tmp.1.$$$$ ./.tmp.2.$$$$ || exit 2; \'
echo ' rm -f ./.tmp.[12].$$$$; \' echo ' rm -f ./.tmp.[12].$$$$; \'
echo ' done; fi' echo ' done; fi'
echo " @if test -f ./sample-${ASN1PDU}-1.xer ; then \\" echo " @if test -f sample-${ASN1PDU}-1.xer ; then \\"
echo " for f in ./sample-${ASN1PDU}-*.xer; do \\" echo " for f in sample-${ASN1PDU}-*.xer; do \\"
echo ' echo "Recoding $$f into DER and back..."; \' echo ' echo "Recoding $$f into DER and back..."; \'
echo ' ./${TARGET} -ixer -oder -b 1 $$f > ./.tmp.1.$$$$ || exit 2; \' echo ' ./${TARGET} -ixer -oder -b 1 $$f > ./.tmp.1.$$$$ || exit 2; \'
echo ' ./${TARGET} -ixer -oder -b 17 $$f > ./.tmp.1.$$$$ || exit 2; \' echo ' ./${TARGET} -ixer -oder -b 17 $$f > ./.tmp.1.$$$$ || exit 2; \'
...@@ -81,8 +81,8 @@ cat Makefile.am.sample \ ...@@ -81,8 +81,8 @@ cat Makefile.am.sample \
echo ' diff $$f ./.tmp.2.$$$$ || exit 2; \' echo ' diff $$f ./.tmp.2.$$$$ || exit 2; \'
echo ' rm -f ./.tmp.[12].$$$$; \' echo ' rm -f ./.tmp.[12].$$$$; \'
echo ' done; fi' echo ' done; fi'
echo " @if test -f ./sample-${ASN1PDU}-1.per ; then \\" echo " @if test -f sample-${ASN1PDU}-1.per ; then \\"
echo " for f in ./sample-${ASN1PDU}-[1-9].per; do \\" echo " for f in sample-${ASN1PDU}-[1-9].per; do \\"
echo ' echo "Recoding $$f into DER into XER and back..."; \' echo ' echo "Recoding $$f into DER into XER and back..."; \'
echo ' ./${TARGET} -iper -oxer -b 1 $$f > ./.tmp.1.$$$$ || exit 2; \' echo ' ./${TARGET} -iper -oxer -b 1 $$f > ./.tmp.1.$$$$ || exit 2; \'
echo ' ./${TARGET} -iper -oxer -b 17 $$f > ./.tmp.2.$$$$ || exit 2; \' echo ' ./${TARGET} -iper -oxer -b 17 $$f > ./.tmp.2.$$$$ || exit 2; \'
...@@ -97,19 +97,20 @@ cat Makefile.am.sample \ ...@@ -97,19 +97,20 @@ cat Makefile.am.sample \
echo ' diff ./.tmp.1.$$$$ ./.tmp.3.$$$$ || exit 2; \' echo ' diff ./.tmp.1.$$$$ ./.tmp.3.$$$$ || exit 2; \'
echo ' rm -f ./.tmp.[1234].$$$$; \' echo ' rm -f ./.tmp.[1234].$$$$; \'
echo ' done; fi' echo ' done; fi'
echo " @if test -f ./sample-${ASN1PDU}-1-padded.per ; then \\" echo " @if test -f sample-${ASN1PDU}-1-padded.per ; then \\"
echo " for f in ./sample-${ASN1PDU}-[1-9]-padded.per; do \\" echo " for f in sample-*-[1-9]-padded.per; do \\"
echo ' pdu=`echo $$f | sed -E -e "s/sample-([A-Za-z-]+)-[0-9].*/\1/"`; \'
echo ' echo "Recoding byte-padded $$f into DER into XER and back..."; \' echo ' echo "Recoding byte-padded $$f into DER into XER and back..."; \'
echo ' ./${TARGET} -per-padded -iper -oxer -b 1 $$f > ./.tmp.1.$$$$ || exit 2; \' echo ' ./${TARGET} -per-padded -p $$pdu -iper -oxer -b 1 $$f > ./.tmp.1.$$$$ || exit 2; \'
echo ' ./${TARGET} -per-padded -iper -oxer -b 17 $$f > ./.tmp.2.$$$$ || exit 2; \' echo ' ./${TARGET} -per-padded -p $$pdu -iper -oxer -b 17 $$f > ./.tmp.2.$$$$ || exit 2; \'
echo ' ./${TARGET} -per-padded -iper -oxer -b 33 $$f > ./.tmp.3.$$$$ || exit 2; \' echo ' ./${TARGET} -per-padded -p $$pdu -iper -oxer -b 33 $$f > ./.tmp.3.$$$$ || exit 2; \'
echo ' ./${TARGET} -per-padded -iper -oxer -b 980 $$f > ./.tmp.4.$$$$ || exit 2; \' echo ' ./${TARGET} -per-padded -p $$pdu -iper -oxer -b 980 $$f > ./.tmp.4.$$$$ || exit 2; \'
echo ' diff ./.tmp.1.$$$$ ./.tmp.2.$$$$ || exit 2; \' echo ' diff ./.tmp.1.$$$$ ./.tmp.2.$$$$ || exit 2; \'
echo ' diff ./.tmp.2.$$$$ ./.tmp.3.$$$$ || exit 2; \' echo ' diff ./.tmp.2.$$$$ ./.tmp.3.$$$$ || exit 2; \'
echo ' diff ./.tmp.3.$$$$ ./.tmp.4.$$$$ || exit 2; \' echo ' diff ./.tmp.3.$$$$ ./.tmp.4.$$$$ || exit 2; \'
echo ' ./${TARGET} -per-padded -iper -oder $$f > ./.tmp.1.$$$$ || exit 2; \' echo ' ./${TARGET} -per-padded -p $$pdu -iper -oder $$f > ./.tmp.1.$$$$ || exit 2; \'
echo ' ./${TARGET} -iber -oxer ./.tmp.1.$$$$ > ./.tmp.2.$$$$ || exit 2; \' echo ' ./${TARGET} -p $$pdu -iber -oxer ./.tmp.1.$$$$ > ./.tmp.2.$$$$ || exit 2; \'
echo ' ./${TARGET} -ixer -oper ./.tmp.2.$$$$ > ./.tmp.1.$$$$ || exit 2; \' echo ' ./${TARGET} -p $$pdu -ixer -oper ./.tmp.2.$$$$ > ./.tmp.1.$$$$ || exit 2; \'
echo ' diff $$f ./.tmp.1.$$$$ || exit 2; \' echo ' diff $$f ./.tmp.1.$$$$ || exit 2; \'
echo ' rm -f ./.tmp.[1234].$$$$; \' echo ' rm -f ./.tmp.[1234].$$$$; \'
echo ' done; fi' echo ' done; fi'
......
...@@ -200,8 +200,8 @@ regen-makefile: ...@@ -200,8 +200,8 @@ regen-makefile:
../sample.makefile.regen ../sample.makefile.regen
check: ${TARGET} check: ${TARGET}
@if test -f ./sample-LDAPMessage-1.[db]er ; then \ @if test -f sample-LDAPMessage-1.[db]er ; then \
for f in ./sample-LDAPMessage-*.[db]er; do \ for f in sample-LDAPMessage-*.[db]er; do \
echo "Recoding $$f into XER and back..."; \ echo "Recoding $$f into XER and back..."; \
./${TARGET} -iber -oxer -b 1 $$f > ./.tmp.1.$$$$ || exit 2; \ ./${TARGET} -iber -oxer -b 1 $$f > ./.tmp.1.$$$$ || exit 2; \
./${TARGET} -iber -oxer -b 17 $$f > ./.tmp.1.$$$$ || exit 2; \ ./${TARGET} -iber -oxer -b 17 $$f > ./.tmp.1.$$$$ || exit 2; \
...@@ -212,8 +212,8 @@ check: ${TARGET} ...@@ -212,8 +212,8 @@ check: ${TARGET}
diff ./.tmp.1.$$$$ ./.tmp.2.$$$$ || exit 2; \ diff ./.tmp.1.$$$$ ./.tmp.2.$$$$ || exit 2; \
rm -f ./.tmp.[12].$$$$; \ rm -f ./.tmp.[12].$$$$; \
done; fi done; fi
@if test -f ./sample-LDAPMessage-1.xer ; then \ @if test -f sample-LDAPMessage-1.xer ; then \
for f in ./sample-LDAPMessage-*.xer; do \ for f in sample-LDAPMessage-*.xer; do \
echo "Recoding $$f into DER and back..."; \ echo "Recoding $$f into DER and back..."; \
./${TARGET} -ixer -oder -b 1 $$f > ./.tmp.1.$$$$ || exit 2; \ ./${TARGET} -ixer -oder -b 1 $$f > ./.tmp.1.$$$$ || exit 2; \
./${TARGET} -ixer -oder -b 17 $$f > ./.tmp.1.$$$$ || exit 2; \ ./${TARGET} -ixer -oder -b 17 $$f > ./.tmp.1.$$$$ || exit 2; \
...@@ -224,8 +224,8 @@ check: ${TARGET} ...@@ -224,8 +224,8 @@ check: ${TARGET}
diff $$f ./.tmp.2.$$$$ || exit 2; \ diff $$f ./.tmp.2.$$$$ || exit 2; \
rm -f ./.tmp.[12].$$$$; \ rm -f ./.tmp.[12].$$$$; \
done; fi done; fi
@if test -f ./sample-LDAPMessage-1.per ; then \ @if test -f sample-LDAPMessage-1.per ; then \
for f in ./sample-LDAPMessage-[1-9].per; do \ for f in sample-LDAPMessage-[1-9].per; do \
echo "Recoding $$f into DER into XER and back..."; \ echo "Recoding $$f into DER into XER and back..."; \
./${TARGET} -iper -oxer -b 1 $$f > ./.tmp.1.$$$$ || exit 2; \ ./${TARGET} -iper -oxer -b 1 $$f > ./.tmp.1.$$$$ || exit 2; \
./${TARGET} -iper -oxer -b 17 $$f > ./.tmp.2.$$$$ || exit 2; \ ./${TARGET} -iper -oxer -b 17 $$f > ./.tmp.2.$$$$ || exit 2; \
...@@ -240,19 +240,20 @@ check: ${TARGET} ...@@ -240,19 +240,20 @@ check: ${TARGET}
diff ./.tmp.1.$$$$ ./.tmp.3.$$$$ || exit 2; \ diff ./.tmp.1.$$$$ ./.tmp.3.$$$$ || exit 2; \
rm -f ./.tmp.[1234].$$$$; \ rm -f ./.tmp.[1234].$$$$; \
done; fi done; fi
@if test -f ./sample-LDAPMessage-1-padded.per ; then \ @if test -f sample-LDAPMessage-1-padded.per ; then \
for f in ./sample-LDAPMessage-[1-9]-padded.per; do \ for f in sample-*-[1-9]-padded.per; do \
pdu=`echo $$f | sed -E -e "s/sample-([A-Za-z-]+)-[0-9].*/\1/"`; \
echo "Recoding byte-padded $$f into DER into XER and back..."; \ echo "Recoding byte-padded $$f into DER into XER and back..."; \
./${TARGET} -per-padded -iper -oxer -b 1 $$f > ./.tmp.1.$$$$ || exit 2; \ ./${TARGET} -per-padded -p $$pdu -iper -oxer -b 1 $$f > ./.tmp.1.$$$$ || exit 2; \
./${TARGET} -per-padded -iper -oxer -b 17 $$f > ./.tmp.2.$$$$ || exit 2; \ ./${TARGET} -per-padded -p $$pdu -iper -oxer -b 17 $$f > ./.tmp.2.$$$$ || exit 2; \
./${TARGET} -per-padded -iper -oxer -b 33 $$f > ./.tmp.3.$$$$ || exit 2; \ ./${TARGET} -per-padded -p $$pdu -iper -oxer -b 33 $$f > ./.tmp.3.$$$$ || exit 2; \
./${TARGET} -per-padded -iper -oxer -b 980 $$f > ./.tmp.4.$$$$ || exit 2; \ ./${TARGET} -per-padded -p $$pdu -iper -oxer -b 980 $$f > ./.tmp.4.$$$$ || exit 2; \
diff ./.tmp.1.$$$$ ./.tmp.2.$$$$ || exit 2; \ diff ./.tmp.1.$$$$ ./.tmp.2.$$$$ || exit 2; \
diff ./.tmp.2.$$$$ ./.tmp.3.$$$$ || exit 2; \ diff ./.tmp.2.$$$$ ./.tmp.3.$$$$ || exit 2; \
diff ./.tmp.3.$$$$ ./.tmp.4.$$$$ || exit 2; \ diff ./.tmp.3.$$$$ ./.tmp.4.$$$$ || exit 2; \
./${TARGET} -per-padded -iper -oder $$f > ./.tmp.1.$$$$ || exit 2; \ ./${TARGET} -per-padded -p $$pdu -iper -oder $$f > ./.tmp.1.$$$$ || exit 2; \
./${TARGET} -iber -oxer ./.tmp.1.$$$$ > ./.tmp.2.$$$$ || exit 2; \ ./${TARGET} -p $$pdu -iber -oxer ./.tmp.1.$$$$ > ./.tmp.2.$$$$ || exit 2; \
./${TARGET} -ixer -oper ./.tmp.2.$$$$ > ./.tmp.1.$$$$ || exit 2; \ ./${TARGET} -p $$pdu -ixer -oper ./.tmp.2.$$$$ > ./.tmp.1.$$$$ || exit 2; \
diff $$f ./.tmp.1.$$$$ || exit 2; \ diff $$f ./.tmp.1.$$$$ || exit 2; \
rm -f ./.tmp.[1234].$$$$; \ rm -f ./.tmp.[1234].$$$$; \
done; fi done; fi
......
...@@ -4777,8 +4777,8 @@ regen-makefile: ...@@ -4777,8 +4777,8 @@ regen-makefile:
../sample.makefile.regen ../sample.makefile.regen
check: ${TARGET} check: ${TARGET}
@if test -f ./sample-DL-DCCH-Message-1.[db]er ; then \ @if test -f sample-DL-DCCH-Message-1.[db]er ; then \
for f in ./sample-DL-DCCH-Message-*.[db]er; do \ for f in sample-DL-DCCH-Message-*.[db]er; do \
echo "Recoding $$f into XER and back..."; \ echo "Recoding $$f into XER and back..."; \
./${TARGET} -iber -oxer -b 1 $$f > ./.tmp.1.$$$$ || exit 2; \ ./${TARGET} -iber -oxer -b 1 $$f > ./.tmp.1.$$$$ || exit 2; \
./${TARGET} -iber -oxer -b 17 $$f > ./.tmp.1.$$$$ || exit 2; \ ./${TARGET} -iber -oxer -b 17 $$f > ./.tmp.1.$$$$ || exit 2; \
...@@ -4789,8 +4789,8 @@ check: ${TARGET} ...@@ -4789,8 +4789,8 @@ check: ${TARGET}
diff ./.tmp.1.$$$$ ./.tmp.2.$$$$ || exit 2; \ diff ./.tmp.1.$$$$ ./.tmp.2.$$$$ || exit 2; \
rm -f ./.tmp.[12].$$$$; \ rm -f ./.tmp.[12].$$$$; \
done; fi done; fi
@if test -f ./sample-DL-DCCH-Message-1.xer ; then \ @if test -f sample-DL-DCCH-Message-1.xer ; then \
for f in ./sample-DL-DCCH-Message-*.xer; do \ for f in sample-DL-DCCH-Message-*.xer; do \
echo "Recoding $$f into DER and back..."; \ echo "Recoding $$f into DER and back..."; \
./${TARGET} -ixer -oder -b 1 $$f > ./.tmp.1.$$$$ || exit 2; \ ./${TARGET} -ixer -oder -b 1 $$f > ./.tmp.1.$$$$ || exit 2; \
./${TARGET} -ixer -oder -b 17 $$f > ./.tmp.1.$$$$ || exit 2; \ ./${TARGET} -ixer -oder -b 17 $$f > ./.tmp.1.$$$$ || exit 2; \
...@@ -4801,8 +4801,8 @@ check: ${TARGET} ...@@ -4801,8 +4801,8 @@ check: ${TARGET}
diff $$f ./.tmp.2.$$$$ || exit 2; \ diff $$f ./.tmp.2.$$$$ || exit 2; \
rm -f ./.tmp.[12].$$$$; \ rm -f ./.tmp.[12].$$$$; \
done; fi done; fi
@if test -f ./sample-DL-DCCH-Message-1.per ; then \ @if test -f sample-DL-DCCH-Message-1.per ; then \
for f in ./sample-DL-DCCH-Message-[1-9].per; do \ for f in sample-DL-DCCH-Message-[1-9].per; do \
echo "Recoding $$f into DER into XER and back..."; \ echo "Recoding $$f into DER into XER and back..."; \
./${TARGET} -iper -oxer -b 1 $$f > ./.tmp.1.$$$$ || exit 2; \ ./${TARGET} -iper -oxer -b 1 $$f > ./.tmp.1.$$$$ || exit 2; \
./${TARGET} -iper -oxer -b 17 $$f > ./.tmp.2.$$$$ || exit 2; \ ./${TARGET} -iper -oxer -b 17 $$f > ./.tmp.2.$$$$ || exit 2; \
...@@ -4817,20 +4817,28 @@ check: ${TARGET} ...@@ -4817,20 +4817,28 @@ check: ${TARGET}
diff ./.tmp.1.$$$$ ./.tmp.3.$$$$ || exit 2; \ diff ./.tmp.1.$$$$ ./.tmp.3.$$$$ || exit 2; \
rm -f ./.tmp.[1234].$$$$; \ rm -f ./.tmp.[1234].$$$$; \
done; fi done; fi
@if test -f ./sample-DL-DCCH-Message-1-padded.per ; then \ @if test -f sample-DL-DCCH-Message-1-padded.per ; then \
for f in ./sample-DL-DCCH-Message-[1-9]-padded.per; do \ for f in sample-*-[1-9]-padded.per; do \
pdu=`echo $$f | sed -E -e "s/sample-([A-Za-z-]+)-[0-9].*/\1/"`; \
echo "Recoding byte-padded $$f into DER into XER and back..."; \ echo "Recoding byte-padded $$f into DER into XER and back..."; \
./${TARGET} -per-padded -iper -oxer -b 1 $$f > ./.tmp.1.$$$$ || exit 2; \ echo "./${TARGET} -per-padded -p $$pdu -iper -oxer -b 1 $$f > ./.tmp.1.$$$$"; \
./${TARGET} -per-padded -iper -oxer -b 17 $$f > ./.tmp.2.$$$$ || exit 2; \ ./${TARGET} -per-padded -p $$pdu -iper -oxer -b 1 $$f > ./.tmp.1.$$$$ || exit 2; \
./${TARGET} -per-padded -iper -oxer -b 33 $$f > ./.tmp.3.$$$$ || exit 2; \ echo "./${TARGET} -per-padded -p $$pdu -iper -oxer -b 17 $$f > ./.tmp.2.$$$$"; \
./${TARGET} -per-padded -iper -oxer -b 980 $$f > ./.tmp.4.$$$$ || exit 2; \ ./${TARGET} -per-padded -p $$pdu -iper -oxer -b 17 $$f > ./.tmp.2.$$$$ || exit 2; \
diff ./.tmp.1.$$$$ ./.tmp.2.$$$$ || exit 1; \ echo "./${TARGET} -per-padded -p $$pdu -iper -oxer -b 33 $$f > ./.tmp.3.$$$$"; \
./${TARGET} -per-padded -p $$pdu -iper -oxer -b 33 $$f > ./.tmp.3.$$$$ || exit 2; \
echo "./${TARGET} -per-padded -p $$pdu -iper -oxer -b 980 $$f > ./.tmp.4.$$$$"; \
./${TARGET} -per-padded -p $$pdu -iper -oxer -b 980 $$f > ./.tmp.4.$$$$ || exit 2; \
diff ./.tmp.1.$$$$ ./.tmp.2.$$$$ || exit 2; \
diff ./.tmp.2.$$$$ ./.tmp.3.$$$$ || exit 2; \ diff ./.tmp.2.$$$$ ./.tmp.3.$$$$ || exit 2; \
diff ./.tmp.3.$$$$ ./.tmp.4.$$$$ || exit 3; \ diff ./.tmp.3.$$$$ ./.tmp.4.$$$$ || exit 2; \
./${TARGET} -per-padded -iper -oder $$f > ./.tmp.1.$$$$ || exit 2; \ echo "./${TARGET} -per-padded -p $$pdu -iper -oder $$f > ./.tmp.1.$$$$"; \
./${TARGET} -iber -oxer ./.tmp.1.$$$$ > ./.tmp.2.$$$$ || exit 2; \ ./${TARGET} -per-padded -p $$pdu -iper -oder $$f > ./.tmp.1.$$$$ || exit 2; \
./${TARGET} -ixer -oper ./.tmp.2.$$$$ > ./.tmp.1.$$$$ || exit 2; \ echo "./${TARGET} -p $$pdu -iber -oxer ./.tmp.1.$$$$ > ./.tmp.2.$$$$"; \
diff $$f ./.tmp.1.$$$$ || exit 4; \ ./${TARGET} -p $$pdu -iber -oxer ./.tmp.1.$$$$ > ./.tmp.2.$$$$ || exit 2; \
echo "./${TARGET} -p $$pdu -ixer -oper ./.tmp.2.$$$$ > ./.tmp.1.$$$$"; \
./${TARGET} -p $$pdu -ixer -oper ./.tmp.2.$$$$ > ./.tmp.1.$$$$ || exit 2; \
diff $$f ./.tmp.1.$$$$ || exit 2; \
rm -f ./.tmp.[1234].$$$$; \ rm -f ./.tmp.[1234].$$$$; \
done; fi done; fi
@echo ================ @echo ================
......
...@@ -1328,8 +1328,11 @@ OCTET_STRING_encode_uper(asn_TYPE_descriptor_t *td, ...@@ -1328,8 +1328,11 @@ OCTET_STRING_encode_uper(asn_TYPE_descriptor_t *td,
sizeinunits = sizeinunits * 8 - (st->bits_unused & 0x07); sizeinunits = sizeinunits * 8 - (st->bits_unused & 0x07);
} }
ASN_DEBUG("Encoding %s into %d units of %d bits", ASN_DEBUG("Encoding %s into %d units of %d bits"
td->name, sizeinunits, unit_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 */ /* Figure out wheter size lies within PER visible consrtaint */
......
...@@ -62,6 +62,7 @@ typedef struct asn_enc_rval_s { ...@@ -62,6 +62,7 @@ typedef struct asn_enc_rval_s {
tmp_error.encoded = -1; \ tmp_error.encoded = -1; \
tmp_error.failed_type = td; \ tmp_error.failed_type = td; \
tmp_error.structure_ptr = sptr; \ tmp_error.structure_ptr = sptr; \
ASN_DEBUG("Failed to encode element %s", td->name); \
return tmp_error; \ return tmp_error; \
} while(0) } while(0)
#define _ASN_ENCODED_OK(rval) do { \ #define _ASN_ENCODED_OK(rval) do { \
...@@ -91,6 +92,7 @@ typedef struct asn_dec_rval_s { ...@@ -91,6 +92,7 @@ typedef struct asn_dec_rval_s {
asn_dec_rval_t tmp_error; \ asn_dec_rval_t tmp_error; \
tmp_error.code = RC_FAIL; \ tmp_error.code = RC_FAIL; \
tmp_error.consumed = 0; \ tmp_error.consumed = 0; \
ASN_DEBUG("Failed to decode element %s", td->name); \
return tmp_error; \ return tmp_error; \
} while(0) } while(0)
#define _ASN_DECODE_STARVED do { \ #define _ASN_DECODE_STARVED do { \
......
...@@ -22,11 +22,7 @@ ber_decode_primitive(asn_codec_ctx_t *opt_codec_ctx, ...@@ -22,11 +22,7 @@ ber_decode_primitive(asn_codec_ctx_t *opt_codec_ctx,
*/ */
if(st == NULL) { if(st == NULL) {
st = (ASN__PRIMITIVE_TYPE_t *)CALLOC(1, sizeof(*st)); st = (ASN__PRIMITIVE_TYPE_t *)CALLOC(1, sizeof(*st));
if(st == NULL) { if(st == NULL) _ASN_DECODE_FAILED;
rval.code = RC_FAIL;
rval.consumed = 0;
return rval;
}
*sptr = (void *)st; *sptr = (void *)st;
} }
...@@ -59,17 +55,13 @@ ber_decode_primitive(asn_codec_ctx_t *opt_codec_ctx, ...@@ -59,17 +55,13 @@ ber_decode_primitive(asn_codec_ctx_t *opt_codec_ctx,
if(sizeof(st->size) != sizeof(length) if(sizeof(st->size) != sizeof(length)
&& (ber_tlv_len_t)st->size != length) { && (ber_tlv_len_t)st->size != length) {
st->size = 0; st->size = 0;
rval.code = RC_FAIL; _ASN_DECODE_FAILED;
rval.consumed = 0;
return rval;
} }
st->buf = (uint8_t *)MALLOC(length + 1); st->buf = (uint8_t *)MALLOC(length + 1);
if(!st->buf) { if(!st->buf) {
st->size = 0; st->size = 0;
rval.code = RC_FAIL; _ASN_DECODE_FAILED;
rval.consumed = 0;
return rval;
} }
memcpy(st->buf, buf_ptr, length); memcpy(st->buf, buf_ptr, length);
...@@ -249,12 +241,7 @@ xer_decode_primitive(asn_codec_ctx_t *opt_codec_ctx, ...@@ -249,12 +241,7 @@ xer_decode_primitive(asn_codec_ctx_t *opt_codec_ctx,
*/ */
if(!*sptr) { if(!*sptr) {
*sptr = CALLOC(1, struct_size); *sptr = CALLOC(1, struct_size);
if(!*sptr) { if(!*sptr) _ASN_DECODE_FAILED;
asn_dec_rval_t rval;
rval.code = RC_FAIL;
rval.consumed = 0;
return rval;
}
} }
memset(&s_ctx, 0, sizeof(s_ctx)); memset(&s_ctx, 0, sizeof(s_ctx));
...@@ -284,8 +271,7 @@ xer_decode_primitive(asn_codec_ctx_t *opt_codec_ctx, ...@@ -284,8 +271,7 @@ xer_decode_primitive(asn_codec_ctx_t *opt_codec_ctx,
/* /*
* This decoder does not like empty stuff. * This decoder does not like empty stuff.
*/ */
rc.code = RC_FAIL; _ASN_DECODE_FAILED;
rc.consumed = 0;
} }
} }
break; break;
...@@ -300,6 +286,8 @@ xer_decode_primitive(asn_codec_ctx_t *opt_codec_ctx, ...@@ -300,6 +286,8 @@ xer_decode_primitive(asn_codec_ctx_t *opt_codec_ctx,
rc.consumed = 0; rc.consumed = 0;
if(s_arg.want_more) if(s_arg.want_more)
rc.code = RC_WMORE; rc.code = RC_WMORE;
else
_ASN_DECODE_FAILED;
break; break;
} }
return rc; return rc;
......
...@@ -665,8 +665,10 @@ data_decode_from_file(asn_TYPE_descriptor_t *pduType, FILE *file, const char *na ...@@ -665,8 +665,10 @@ data_decode_from_file(asn_TYPE_descriptor_t *pduType, FILE *file, const char *na
* Print a message and return failure only if not EOF, * Print a message and return failure only if not EOF,
* unless this is our first PDU (empty file). * unless this is our first PDU (empty file).
*/ */
if((on_first_pdu || new_offset != old_offset || DynamicBuffer.length) if(on_first_pdu
&& (iform != INP_XER || on_first_pdu)) { || DynamicBuffer.length
|| new_offset - old_offset > ((iform == INP_XER)?sizeof("\r\n")-1:0)
) {
DEBUG("ofp %d, no=%ld, oo=%ld, dbl=%ld", DEBUG("ofp %d, no=%ld, oo=%ld, dbl=%ld",
on_first_pdu, (long)new_offset, (long)old_offset, on_first_pdu, (long)new_offset, (long)old_offset,
(long)DynamicBuffer.length); (long)DynamicBuffer.length);
......
...@@ -173,6 +173,8 @@ xer_check_tag(const void *buf_ptr, int size, const char *need_tag) { ...@@ -173,6 +173,8 @@ xer_check_tag(const void *buf_ptr, int size, const char *need_tag) {
#define RETURN(_code) do { \ #define RETURN(_code) do { \
rval.code = _code; \ rval.code = _code; \
rval.consumed = consumed_myself; \ rval.consumed = consumed_myself; \
if(rval.code != RC_OK) \
ASN_DEBUG("Failed with %d", rval.code); \
return rval; \ return rval; \
} while(0) } while(0)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment