Skip to content

Exception thrown when decoding the attribute-values sequence within an initial vocabulary where an attribute value length is > 9 #49

Description

@Tomas-Kraus

When decoding a Fast Infoset file which contains an initial vocabulary, the Decoder class throws an exception if the initial vocabulary contains attribute values with length > 8. From some investigation, it appears that the decoder parses the attribute-values sequence incorrectly, treating the individual string values as a "NonEmptyOctetString starting on the 2nd bit of an octet (C.22)", rather than "NonEmptyOctetString starting on the fifth bit of an octet(C.23)". This results in the decoder not being able to properly determine the length of a string when a message which contains a length > 8 is encountered since the length of the string is calculated differently between C.22 and C.23.

Some more background:
attribute-values in the initial vocabulary is treated as an EncodedCharacterString (C.19). The current method to parse attribute-values in the code is to call this function in the Decoder.decodeInitialVocabulary(), since in the ParserVocabulary class, attributeValues is treated as a StringArray:

private void decodeTableItems(StringArray array) throws FastInfosetException, IOException {
final int noOfItems = decodeNumberOfItemsOfSequence();

for (int i = 0; i < noOfItems; i++)

{ array.add(decodeNonEmptyOctetStringOnSecondBitAsUtf8String()); }

}

The call path within decodeNonEmptyOctetStringOnSecondBitAsUtf8String() is the problem, as that decodes the strings within the set as 2 bit offset NonEmptyOctetStrings (C.22), instead of 5 bit offset NonEmptyOctetStrings (C.23).

The code to decode a 5 bit offset NonEmptyOctetString (C.23) is intermixed within decodeNonIdentifyingStringOnFirstBit(), which is trying to decode a NonIdentifyingStringOrIndex (C.14), where that type actually includes strings encoded as a 5 bit offset NonEmptyString.

There are probably a handful of ways to fix this, but one shortcut is to create a new function based upon decodeNonIdentifyingStringOnFirstBit() which removes the code that's specific to the unique properties of C.14. I'll post a snippet of a fix shortly.

Affected Versions

[1.2.12]

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions