Skip to content

UPER: incorrect handling of normally small length determinant #523

@zhouxt1

Description

@zhouxt1

Hi, I find that the handling of normally small length determinants might be incorrect in UPER.

Notably, in /per/de.rs,

        // The length bitfield has a lower bound of `1..`
        let extensions_length = self.parse_normally_small_integer::<usize>()? + 1;
        let (input, bitfield) = nom::bytes::streaming::take(extensions_length)(self.input)
            .map_err(|e| DecodeError::map_nom_err(e, self.codec()))?;
        self.input = input;

It uses a parse_normally_small_integer. However, the standard says you should decode a normally small length (X.691 Section 11.9.3.4) when parsing the number of extensions, and this normally small length is different from a normally small non-negative whole number.

Notably, when normally small length's first bit is 1, it is encoded as a length determinant, but for the function parse_normally_small_integer, it is parsed as a non-negative whole number, which is wrong. So the parsed value would be incorrect.

Could you look into this potential non-compilance issue? Thank you

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/codecRelated to a new or existing ASN.1 codec.good first issueGood for newcomershelp wantedExtra attention is neededkind/bugSomething isn't working

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions