Skip to content

no checking of numerical parameter values #3

Description

@dnalor

given

		ARGPARSE_OPTION(INT, 'n', "--number", &opt_n, "int nr"),

running the following will "successfully" result in opt_n=0

./prg -n WTF
./prg -n " "
./prg -n \?

same issue for FLOAT

cause: YOLO-style use of strtol / strtof:
in update_value:

       res = string ? strtol(value, NULL, 0) : *(int *)value;

and

        *(float *)arg->value_ = string ? strtof(value, NULL) : *(float *)value;

see strtol(3) and strtod(3) on why

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions