Age | Commit message (Collapse) | Author |
|
Wrong fields in the record where checked when sorting, which caused
duplicate objects to exist in constructed object sets and later caused
an error.
|
|
|
|
Also add proper error handling.
|
|
File names and line number information was not reliable available
when producing error messages. Some items have embedded line number
information, and sometimes the S#state.type and/or S#state.value
could be used to retrieve the line number information.
To make sure that we can always retrieve at least an approximate
error location, store the top-level construct being checked in
S#state.error_context. Example of top-level constructs:
Seq ::= SEQUENCE {...}
i INTEGER ::= 42
This is a short-term solution. In the long term, we would want the
parser to include line number information in all items.
|
|
Rewrite the confusing and buggy matching of an object definition
against the simplified syntax.
While we are at it, we will also add proper error handling.
|
|
When the parser sees:
something SOMETHING ::= {}
it has no way of knowing whether 'something' is an value or an
object. It depends on how SOMETHING is defined. For example:
SOMETHING ::= SEQUENCE {}
or
SOMETHING ::= CLASS { &id OPTIONAL }
Because of that ambiguity, there is no way to avoid a special case
when we check an object definition. However, there is no need to
invent an entire new checking function for this special case. It is
much easier to just pretend that the parser gave us
{object,defaultsyntax,[]} and let check_objectdefn/3 check it in the
usual way.
|
|
An #'Externavaluereference'{} may either be a value or an object.
In places where objects are expected, we will need to call
object_to_check/1 to convert an #'Externavaluereference'{} to an
object. It was forgotten in two places.
|
|
Refactor and clean up code. While at it, add error handling and
test cases. (Also add test cases for the existing values in
ValueTest.asn while we are it.)
Add support for defining INTEGER constants by extracting
fields from objects. Example:
int-from-object INTEGER ::= object.&id
When extracting values from objects in constraints, only one
level of extraction would work. That is, the following would
work:
SomeName ::= INTEGER (object.&int)
but not:
SomeName ::= INTEGER (object.&obj.&int)
|
|
There is duplicated effort in that validate_integer() checks
whether the integer value is valid, and then normalize_integer()
does mostly the same work in order to convert the value to an
integer.
Eliminate the validate_integer() function and incorporate
its checks into normalize_integer(). Also produce proper
error messages.
|
|
Class names must start with an uppercase letter and only contain
uppercase letters, digits, or hyphens. The parser will not allow
class names that don't start with an uppercase letter, so we don't
have to check that.
|
|
Don't build a record using the tuple syntax. It is bad in case
we would want to change the record definition later.
|
|
|
|
* dgud/asn1/fix-seqtag/OTP-12326:
asn1: Fix EXTERNAL (1994 variant) type conversion
|
|
Missed to add seqtag handling for EXTERNAL type conversion,
bug introduced in c266196c016fc1156c7a18cfeec4920ee4075519
|
|
This patch fixes a bug with compliance to X.680 (200811) s31.2.7
Basically, when TagDefault is AUTOMATIC then
tags are IMPLICIT unless EXPLICIT is given.
|
|
The following type of code would crash the compiler:
OSET SOME-CLASS ::= {OSET1, ..., OSET2}
|
|
The previous code looked at the actual parameters supplied when
instantiating the type to determine the type of the argument; the
correct way is to determine the type by looking at the governor and
case of the formal parameter.
|
|
Check the formal parameters for a parameterized type definition.
If the governor for a formal parameter is absent, the formal parameter
must be in upper case.
|
|
Definitions for parameterized types are verified once very early,
and one more time when they are instantiated.
Errors found during the first check were ignored, so errors for
unused parameterized types were not reported.
|
|
Before classes were fully implemented, there was support for
ABSTRACT-SYNTAX and TYPE-IDENTIFIER. Some of that code is still
there and is no longer used. Get rid of it and correct comments.
|
|
Attempting to compile:
SomeType{SOME-CLASS-NAME, SOME-CLASS-NAME:SomeSet} ::= ...
SEQUENCE {
something SOME-CLASS-NAME.&id({SomeSet})
}
would crash the compiler, because the actual parameter for
SOME-CLASS-NAME was not substituted into the governor for
the SomeSet parameter.
While we are at it, combine the functionality of is_class/2
and get_class_def/2 (eliminating is_class/2). Most callers
call both function.
|
|
If we want construct an #'Externaltypereference'{} from
a #classdef{} record, we will need the module name.
|
|
The only remaining use of #identifier{} in asn1ct_check was in a
temporary packaging of a value that would be ultimately be put
into #valuedef{}.
Therefore we can eliminate that last usage but putting the value
directly into a #valuedef{} and we can move the record definition
into asn1ct_parser2.
|
|
When parsing ASN.1, certain constructs can only be understood in
the full context of the entire ASN.1 module.
For instance, the value following ID in this simplified excerpt
from MTSAbstractService88:
administration-88 PORT ::= {
ID {id-pt-administration 88}
}
the value following "ID" can be interpreted either as value
for:
SEQUENCE {
id-pt-administration INTEGER
}
or as an OBJECT IDENTIFIER.
Our ASN.1 parser assumes that a SEQUENCE is meant, and if that
later turns out to be wrong, the SEQUENCE value is rewritten to
an OBJECT IDENTIFIER. The problem is that at the time of the
rewrite, we no longer know in which ASN.1 module id-pt-administration
was defined in, and we have to use the module name in the state{}
record. Unfortunately, the module name in the state{} record may
not always be correct.
While there are attempts in the code to keep the module name
up-to-date when checking imported types, it is not done consistently,
and it seems to be a difficult and error-prone task to attempt
to make it consistent.
A safer and less error-prone approach is to make sure that we
don't lose the module name while parsing. To make it clear what
we are doing, we will introduce a new #seqtag{} record that
are used for tags in SEQUENCE values. The name is based on its
primary use. The record also contains the module in case it happens
to be an OBJECT IDENTIFIER.
|
|
Make sure that we continue to follow external references until
we find a real type.
|
|
|
|
|
|
This will also eliminate a dialyzer warning for unmatched returns,
and increase the coverage.
|
|
The error checking code for INTEGER and BIT STRING was broken,
since it built an error tuple that was never returned.
Rewrite the error checking code, sharing most of the code between
INTEGER and BIT STRING. Make sure that we test for both duplicated
names and number, as well as for negative bit numbers for
BIT STRING.
This rewrite will eliminate two dialyzer warnings for unmatched
returns.
|
|
A named number list as used for ENUMERATED and INTEGER can never
have an {identifier,...} tuple in its third position like this:
{'NamedNumber',Id,{identifier,_,_}}
because asn1ct_parser2:parse_NamedNumber/1 will always replace
an identifier tuple with an #Externaluereference{} record.
|
|
Since most calls to asn1_error/3 throw its result, it makes more
sense to let asn1_error/3 itself throw the error tuple. Add the
return_asn1_error/3 to return the error tuple to use when we don't
want to throw it.
|
|
* bjorn/asn1/cleanup/OTP-11727:
asn1ct_check: Use a return value to silence a dialyzer warning
asn1ct_check: Remove useless call to check_integer/3
asn1ct_check: Correct error handling for illegal OCTET STRING values
asn1ct: Silence dialyzer warnings for unmatched returns
asn1ct_table: Remove unused flexibility in table creation
asn1ct_table: Silence a dialyzer warning for unmatched return
asn1ct_gen: Silence dialyzer warnings for unmatched returns
asn1ct_value: Silence a dialyzer warning for unmatched return
asn1ct_tok: Check return value from file:close/1
|
|
Attempting to subtype an extensible ENUMERATED like this:
BaseType ::= { foo, bar, ... }
SubType ::= BaseType ( foo )
would fail to compile with a message that 'foo' was undefined.
Reported-by: Morten Nygaard Åsnes
|
|
Unfortunately the code in question is not covered by our test
suites, but it should be correct to do the same thing as in
the clause above.
|
|
check_integer/3 can check nothing for an INTEGER without any named
values. Remove the useless call to silence a dialyzer warning for
unmatched return.
|
|
The value for an OCTET STRING must be specified as either a bstring
or an hstring. Everything else (including character strings) is
illegal.
This correction also removes the offending code that caused an
unmatched return warning from dialyzer.
|
|
|
|
* bjorn/asn1/fix-union-bug/OTP-11411:
Fix complicated union of INTEGER constraints
|
|
A constraint that was an union of integer ranges:
Type ::= INTEGER (lb1..ub1 | ... | lbN..ubN)
would sometimes (depending on the values) not all always be properly
combined to a single effective range, but would become:
Type ::= INTEGER (lb2..ub2) (lb3..ub3)
If that type was used in a SEQUENCE:
S ::= SEQUENCE {
v Type
}
the constraint would be simplified, taking the intersection of the
ranges.
|
|
For DER/PER/UPER, a value equal to the DEFAULT is not supposed to
be encoded.
BIT STRINGs values can be represented as Erlang terms in four
different ways: as an integer, as a list of zeroes and ones,
as a {Unused,Binary} tuple, or as an Erlang bitstring.
When encoding a BIT STRING, only certain representations of
BIT STRINGs values were recognized. All representations must
be recognized.
When decoding a DEFAULT value for a BIT STRING, the actual value
given in the decoding would be either an integer or a list
of zeroes and one (depending on how the literal was written in
the specification). We expect that the default value should be
in the same representation as any other BIT STRING value (i.e.
by default an Erlang bitstring, or a list if the 'legacy_bitstring'
option has been given, or as compact bitstring if 'compact_bitstring'
has been given).
|
|
There is (differenct) code for reading .asn1db files both in
asn1ct and asn1_db. Consolidate the reading into one routine
in asn1db.
Another problem is that the encoding rule that the .asn1db
file was created for is not in the .asn1db, but only in the
generated Erlang module. It is much easier and safer to put
the encoding rule in the .asn1db file itself. We will also
put the version number of the asn1 application into the file,
to ensure that we don't use an old .asn1db file that could
potentially be incompatible.
|
|
|
|
The Per argument is no longer used; it is only passed around.
|
|
Simplify the backends by letting asn1ct_check replacing a
with the actual type.
|
|
The name of the referenced object set name in #simpletableattributes{}
would when used by INSTANCE OF be an atom, but in all other cases
be a {Module,ObjectSetName} tuple. Simplify the code by always using
the latter format.
|
|
Most types don't have any validation functions that does anything
useful, so it is sufficient to call normalize_value/4 for them.
|
|
Unify the code for checking an enumeration value named in a
DEFAULT and in an ENUMERATED value. There is no need to handle
those cases differently. That also will also make sure that
the following works:
E ::= ENUMERATED { x, ..., y }
e E ::= x
(Extensible ENUMERATEDs were not handled when defining values.)
Always generate an error when an unknown enumeration value is
given (used in a DEFAULT, a message would be printed, but the
compilation would succeed). Also make sure that we always include
the line number for the incorrect enumeration.
Write a new test case and remove the extremely rudimentary
value_bad_enum_test/1 test case.
|
|
|
|
|
|
|