Skip to content

Commit

Permalink
MDEV-22219: error on parsing negative unsigned options
Browse files Browse the repository at this point in the history
  • Loading branch information
grooverdan committed Apr 7, 2021
1 parent 609e8e3 commit 46852b3
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions mysys/my_getopt.c
Original file line number Diff line number Diff line change
Expand Up @@ -1040,21 +1040,30 @@ static ulonglong eval_num_suffix_ull(char *argument,
ulonglong num;
DBUG_ENTER("eval_num_suffix_ull");

if (*argument == '-')
{
my_getopt_error_reporter(ERROR_LEVEL,
"Incorrect unsigned value: '%s' for %s",
argument, option_name);
*error= 1;
DBUG_RETURN(0);
}
*error= 0;
errno= 0;
num= strtoull(argument, &endchar, 10);
if (errno == ERANGE)
{
my_getopt_error_reporter(ERROR_LEVEL,
"Incorrect integer value: '%s'", argument);
"Incorrect integer value: '%s' for %s",
argument, option_name);
*error= 1;
DBUG_RETURN(0);
}
num*= eval_num_suffix(endchar, error);
if (*error)
fprintf(stderr,
"Unknown suffix '%c' used for variable '%s' (value '%s')\n",
*endchar, option_name, argument);
my_getopt_error_reporter(ERROR_LEVEL,
"Unknown suffix '%c' used for variable '%s' (value '%s')",
*endchar, option_name, argument);
DBUG_RETURN(num);
}

Expand Down

0 comments on commit 46852b3

Please sign in to comment.