Skip to content

Incorrect handling of "--" in GNU mode #106

Open
@FerrumBrain

Description

@FerrumBrain

Next entries are considered options when -- is encountered in GNU mode. However, there is no check to ensure that they exist.
In the following test case:

val parser = ArgParser("").apply {
    argument(ArgType.String, fullName = "")
    prefixStyle = ArgParser.OptionPrefixStyle.GNU
}    

val args = arrayOf("--")
parser.parse(args)

Many results can be considered correct:

  • String "--" is interpreted as a delimiter between options and arguments, parsing is successful with no options and no arguments
  • String "--" is interpreted as an argument and parsing is successful
  • String "--" is interpreted as a start of the option and the parser fails with a descriptive error because no options are registered

In practice though, it throws an ArrayOutOfBoundsException.
Bug is found by fuzzing team @ PLAN Lab.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions