CadixDev / Bombe

A model of Java types, as per the JVMS specification.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Potential to read malformed object type

jamierocks opened this issue · comments

If a consumer calls TypeReader#readObjectType() directly - they may inadvertantly read a malformed input.

    public ObjectType readObjectType() {
        final int start = this.index();
        this.advance();

        while (this.available() && this.peek() != ';') {
            this.advance();
        }

        if (this.peek() != ';') throw new IllegalStateException("Incomplete descriptor provided!");
        this.advance();

        return new ObjectType(this.substring(start + 1, this.index() - 1));
    }

There is no validation that the first character is L - therefore any character could be in its place. This is not a problem with readType() or readFieldType() as they will only pass onto readObjectType() in the circumstance that the check that needs be introduced here is done.

  • An exception should be thrown when calling readObjectType() with the input Cjava/lang/String;