aboutsummaryrefslogtreecommitdiffstats
path: root/lib/asn1/src/asn1ct_check.erl
AgeCommit message (Collapse)Author
2014-02-28Clean up reporting of errors in IMPORTSBjörn Gustavsson
2014-02-28asn1ct_check: Clean up error checking for INSTANCE OFBjörn Gustavsson
This will also eliminate a dialyzer warning for unmatched returns, and increase the coverage.
2014-02-28asn1ct_check: Rewrite error checking for INTEGER and BIT STRINGBjörn Gustavsson
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.
2014-02-28asn1ct_check: Remove unreachable clauses handling {identifier,_,_}Björn Gustavsson
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.
2014-02-28asn1ct_check: Let asn1_error/3 throw its resultBjörn Gustavsson
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.
2014-02-20Merge branch 'bjorn/asn1/cleanup/OTP-11727'Björn Gustavsson
* 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
2014-02-13Correct subtyping of extensible ENUMERATEDBjörn Gustavsson
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
2014-01-31asn1ct_check: Use a return value to silence a dialyzer warningBjörn Gustavsson
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.
2014-01-31asn1ct_check: Remove useless call to check_integer/3Björn Gustavsson
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.
2014-01-31asn1ct_check: Correct error handling for illegal OCTET STRING valuesBjörn Gustavsson
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.
2014-01-24Fix OCTET STRINGBjörn Gustavsson
2013-11-20Merge branch 'bjorn/asn1/fix-union-bug/OTP-11411' into maintBjörn Gustavsson
* bjorn/asn1/fix-union-bug/OTP-11411: Fix complicated union of INTEGER constraints
2013-10-17Fix complicated union of INTEGER constraintsBjörn Gustavsson
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.
2013-10-01Fix broken handling of default values for BIT STRINGsBjörn Gustavsson
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).
2013-09-03Clean up handling of .asn1db filesBjörn Gustavsson
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.
2013-08-30Clean up checking of objectsBjörn Gustavsson
2013-05-31asn1ct_check: Eliminate useless Per argument from complist_as_tuple()Björn Gustavsson
The Per argument is no longer used; it is only passed around.
2013-05-31asn1ct_check: Don't pass on #'ObjectClassFieldType'{} with fixed typeBjörn Gustavsson
Simplify the backends by letting asn1ct_check replacing a with the actual type.
2013-05-31Normalize data representation for table constraintsBjörn Gustavsson
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.
2013-05-31asn1ct: Simplify check_value/2Björn Gustavsson
Most types don't have any validation functions that does anything useful, so it is sufficient to call normalize_value/4 for them.
2013-05-31Clean up checking of values for ENUMERATEDsBjörn Gustavsson
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.
2013-05-31Introduce a new mechanism for structured error handlingBjörn Gustavsson
2013-05-31asn1ct_check: Clean up checkc/3Björn Gustavsson
2013-05-31asn1ct_check: Clean up checkp/3Björn Gustavsson
2013-05-31asn1ct_check: Clean up checkv/3Björn Gustavsson
2013-05-31asn1ct_check: Introduce check_fold/3 and clean up checkt/3Björn Gustavsson
Capture the common pattern of checking a list of named ASN.1 items in a check_fold/3 function. Clean up checkt/3 using it, replacing the old-style catch with a try..catch.
2013-05-31Eliminate clauses that can never matchBjörn Gustavsson
Dialyzer issued two new warnings when the 'catch' was removed in the previous commit.
2013-05-31asn1ct_check: Simplify code at the end of check_type/3Björn Gustavsson
The code does record operations one step at the time and checks for conditions that cannot happen.
2013-05-31Normalize SIZE constraints to simplify backendsBjörn Gustavsson
2013-05-31Fix handling of open interval constraints with pre-defined integersBjörn Gustavsson
The compiler would crash when given code such as the following: Type ::= INTEGER (lower<..<upper) lower INTEGER ::= 0 lower INTEGER ::= 42
2013-05-31Eliminate use of #constraint{} outside of the parserBjörn Gustavsson
The record #constraint{} is almost unused outside of the parser except for two places in asn1ct_check. The only correct usage of the record is in instance_of_constraints/2. Eliminate that usage by updating the parser to pass that constraint in the same way as all other constraints. In check_integer_range/2, the record is used incorrectly. A constraint for an integer will never be a list of #constraint{} records. Therefore, the list comprehension will always produce an empty list, and check_constr/2 will not actually check anything (which is kind of lucky, since the 'ValueRange' range constraint is incorrectly written - the lower and upper bounds should be in a tuple). For now, we will not attempt to actually start validating integer ranges. Firstly (obviously) we will need to be sure that we correctly handles all forms of constraints, and secondly we will need to consider whether we need to produce a warning rather than an error for compatibility reasons.
2013-05-31ascn1ct_check: Remove effect-less codeBjörn Gustavsson
2013-05-31Eliminate general use of #typereference{}Björn Gustavsson
The record #typereference{} is only used internally within the asn1ct_parser2 module (the parser translates it to an #'Externaltypereference{} record).
2013-04-16Merge branch 'bjorn/asn1/fix-lost-extension-mark/OTP-10995' into maint-r16Erlang/OTP
* bjorn/asn1/fix-lost-extension-mark/OTP-10995: Prevent loss of objects after the extension marker Don't lose the extension mark for object set parameters
2013-04-03Prevent loss of objects after the extension markerBjörn Gustavsson
In an object set with a single root object, objects after the extension marker would be lost.
2013-04-03Don't lose the extension mark for object set parametersBjörn Gustavsson
When an object set is an actual parameter, the extension marker for the object set could get lost.
2013-02-22Update copyright yearsBjörn-Egil Dahlberg
2013-02-16asn1ct: Eliminate use of obsolete size/1Björn Gustavsson
Also teach otp_SUITE:call_to_size/1 that calls to size/1 is no longer allowed within the asn1 application.
2012-12-18Add a test case for constraint equivalenceBjörn Gustavsson
The constraint simplification pass need to be seriously rethought and rewritten. As a starting point, add a test case to test that equivalent ways to write a constraint are reduced to the same simplified constraint. Fix a few obvious bugs to make the test cases to pass.
2012-11-26Fix BER encoding when multiple levels of typedefs are usedBjörn Gustavsson
2012-11-26Remove the unused asn1ct_gen_ber moduleBjörn Gustavsson
2012-11-23Remove obsolete back-ends and simplify the optionsBjörn Gustavsson
It is time to clean up the mess of back-ends. Remove all the obsolete back-ends and simplify the options used to select them. New Option Old Equivalent ---------- -------------- ber ber_bin,optimize,nif per per,optimize,nif uper uper_bin The old options will still be recognized and translated to the new options, but will also print a warning. That implies that deprecated features that only are implemented in the old 'ber' back-end will no longer work (e.g. the {Typename,Value} notation). Also make the return type for the generated encode/2 function consistent. It used to be a binary for per and uper, and an iolist for ber. Always make it a binary.
2012-07-05Add sorting in constraint checking on single values.Gustav Simonsson
Fix a bug where a subtyped single value integer type where one or more values were predefined would result in generated encoding code having faulty range checks. See seq12102. OTP-10139
2012-05-04Add support for multiple ExtensionAdditionGroupsKenneth Lundin
2012-03-27Correct handling of INTEGER (1..4 | 8 | 10 | 20)Kenneth Lundin
2012-02-28[asn1] Make tables and processes unnamedAdam Lindberg
- Refactor and clean up asn1_db process - Remove unused stop function in asn1ct.erl - Remove infinite loop possibilites in asn1ct_check.erl - test/1,2,3 now run in separate process - Update documentation for new test options
2012-02-28[asn1] Abstract out table access to new moduleAdam Lindberg
All table access is now performed in a separate module. This will allow changes to how ETS is handled by changing only this module. Note that the module exports a very ETS-like interface for now which would have to be maintained even if the data format would change (to a hash map for example).
2012-02-13Fix to integer and sequence definitionsGustav Simonsson
Enable re-use of integer definitions in subsequent definitions and added clauses to check greatest common range for sequence definitions
2011-09-08asn1ct: add warnings_as_errors optionTuncer Ayaz
2011-03-07Fixed crash in asn1ct_check occuring for SEQUENCE with extension mark and ↵Kenneth Lundin
component relation attribute.