summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Black <daniel@linux.ibm.com>2020-04-11 15:03:54 +1000
committerDaniel Black <daniel@mariadb.org>2021-04-07 14:04:55 +1000
commit46852b3bbb1c31421d7eec9119e73190bb4f253e (patch)
treede6e3fd3a189937b22cd62008398cbf4b529bca7
parent609e8e38bb0e5c80a80c77c451b6e519f9aeb386 (diff)
downloadmariadb-git-46852b3bbb1c31421d7eec9119e73190bb4f253e.tar.gz
MDEV-22219: error on parsing negative unsigned options
-rw-r--r--mysys/my_getopt.c17
1 files changed, 13 insertions, 4 deletions
diff --git a/mysys/my_getopt.c b/mysys/my_getopt.c
index 9747ee4214e..3fe025ba808 100644
--- a/mysys/my_getopt.c
+++ b/mysys/my_getopt.c
@@ -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);
}