Commit 7c9e9237 authored by Lev Walkin's avatar Lev Walkin

fixed limits accounting

parent 28c89eb4
...@@ -80,7 +80,7 @@ an ASN.1 standard and compiler may fail to produce the meaningful code. ...@@ -80,7 +80,7 @@ an ASN.1 standard and compiler may fail to produce the meaningful code.
.TP .TP
.B \-fnative-types .B \-fnative-types
Use the native machine's data types (int, double) whenever possible, Use the native machine's data types (int, double) whenever possible,
instead of the compound ASN.1 INTEGER_t, ENUMERATED_t and REAL_t types. instead of the compound INTEGER_t, ENUMERATED_t and REAL_t types.
.TP .TP
.B \-fno-constraints .B \-fno-constraints
Do not generate ASN.1 subtype constraint checking code. This may make a shorter executable. Do not generate ASN.1 subtype constraint checking code. This may make a shorter executable.
...@@ -89,7 +89,9 @@ Do not generate ASN.1 subtype constraint checking code. This may make a shorter ...@@ -89,7 +89,9 @@ Do not generate ASN.1 subtype constraint checking code. This may make a shorter
Enable unnamed unions in the definitions of target language's structures. Enable unnamed unions in the definitions of target language's structures.
.TP .TP
.B \-ftypes88 .B \-ftypes88
Use only ASN.1:1988 embedded types. Pretend to support only ASN.1:1988 embedded types. Certain reserved words,
such as UniversalString and BMPString, become ordinary type references
and may be redefined by the specification.
.SH OUTPUT OPTIONS .SH OUTPUT OPTIONS
.TP .TP
.B \-print-constraints .B \-print-constraints
......
...@@ -313,7 +313,7 @@ usage(const char *av0) { ...@@ -313,7 +313,7 @@ usage(const char *av0) {
" -fnative-types Use \"int\" instead of INTEGER_t whenever possible\n" " -fnative-types Use \"int\" instead of INTEGER_t whenever possible\n"
" -fno-constraints Do not generate constraint checking code\n" " -fno-constraints Do not generate constraint checking code\n"
" -funnamed-unions Enable unnamed unions in structures\n" " -funnamed-unions Enable unnamed unions in structures\n"
" -ftypes88 Use only ASN.1:1988 embedded types\n" " -ftypes88 Pretend to support only ASN.1:1988 embedded types\n"
"\n" "\n"
" -print-constraints Explain subtype constraints (debug)\n" " -print-constraints Explain subtype constraints (debug)\n"
......
...@@ -301,11 +301,17 @@ static pd_code_e process_deeper(const char *fname, FILE *fp, int level, ssize_t ...@@ -301,11 +301,17 @@ static pd_code_e process_deeper(const char *fname, FILE *fp, int level, ssize_t
* This is a constructed type. Process recursively. * This is a constructed type. Process recursively.
*/ */
printf(">\n"); /* Close the opening tag */ printf(">\n"); /* Close the opening tag */
if(tlv_len != -1 && limit != -1) {
assert(limit >= tlv_len);
}
pdc = process_deeper(fname, fp, level + 1, pdc = process_deeper(fname, fp, level + 1,
tlv_len == -1 ? limit : tlv_len, tlv_len == -1 ? limit : tlv_len,
&dec, tlv_len == -1); &dec, tlv_len == -1);
if(pdc == PD_FAILED) return pdc; if(pdc == PD_FAILED) return pdc;
if(limit != -1) limit -= dec; if(limit != -1) {
assert(limit >= dec);
limit -= dec;
}
*decoded += dec; *decoded += dec;
if(tlv_len == -1) { if(tlv_len == -1) {
tblen = 0; tblen = 0;
...@@ -316,7 +322,10 @@ static pd_code_e process_deeper(const char *fname, FILE *fp, int level, ssize_t ...@@ -316,7 +322,10 @@ static pd_code_e process_deeper(const char *fname, FILE *fp, int level, ssize_t
if(print_V(fname, fp, tlv_tag, tlv_len)) if(print_V(fname, fp, tlv_tag, tlv_len))
return PD_FAILED; return PD_FAILED;
limit -= tlv_len; if(limit != -1) {
assert(limit >= tlv_len);
limit -= tlv_len;
}
*decoded += tlv_len; *decoded += tlv_len;
} }
......
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