Sliding PER decoder doesn't work
Summary
A decoder external function, when declared with the 'sliding' prototype, has all of its decoding errors set to warnings, so it can produce a different return value depending on whether there wasn't enough data in the buffer to decode one full value, or whether the buffer actually contains invalid data.
A PER decoder external function, with the 'sliding' prototype, will keep attempting to read from the buffer, even if there isn't any more data.
Steps and/or TTCN-3 code to reproduce
ASN.1 type definition:
Seq ::= SEQUENCE {
f1 [1] OCTET STRING,
f2 [0] OCTET STRING,
f3 [16] OCTET STRING OPTIONAL,
...,
e1 OCTET STRING,
e2 [2] OCTET STRING,
[[
g1 [3] OCTET STRING,
g2 [4] OCTET STRING OPTIONAL
]],
e3 [7] INTEGER (2),
...,
f4 [15] OCTET STRING DEFAULT ''H
}
Decoding in TTCN-3:
external function f_dec_seq(inout octetstring buf, out Seq x) return integer
with { extension "prototype(sliding) decode(PER:PER_ALIGNED)" }
control {
var octetstring buf := 'E001120134015601780660030001'O;
var Seq y;
res := f_dec_seq(buf, y);
action(res);
action(y);
action(buf);
}
What is the current bug behavior?
The decoder reads from unallocated memory, resulting in either a segmentation fault, or the decoded value containing memory garbage.
What is the expected correct behavior?
The decoder should stop, when it reaches the end of the buffer, even if decoding errors are set to warnings.
Relevant logs and/or screenshots
Possible fixes
Throw a different exception in this case, and catch it in the top-level type's 'decode' function.
Titan version
10.0.0
Platform details (OS type and version)
Ubuntu2204
/cc @aknappqwt @mmagyari