Fix incorrect casts in my_getopt code that capped the maximum of longlong
options to the wrong value. (Bug #12925)
This commit is contained in:
parent
ab2caf6de8
commit
e8eed35c6a
@ -6,7 +6,7 @@
|
|||||||
# var/log/mysql_client_test.trace
|
# var/log/mysql_client_test.trace
|
||||||
|
|
||||||
--disable_result_log
|
--disable_result_log
|
||||||
--exec echo $MYSQL_CLIENT_TEST
|
--exec echo $MYSQL_CLIENT_TEST --getopt-ll-test=25600M
|
||||||
--exec $MYSQL_CLIENT_TEST
|
--exec $MYSQL_CLIENT_TEST --getopt-ll-test=25600M
|
||||||
|
|
||||||
# End of 4.1 tests
|
# End of 4.1 tests
|
||||||
|
@ -689,10 +689,10 @@ static longlong getopt_ll(char *arg, const struct my_option *optp, int *err)
|
|||||||
ulonglong block_size= (optp->block_size ? (ulonglong) optp->block_size : 1L);
|
ulonglong block_size= (optp->block_size ? (ulonglong) optp->block_size : 1L);
|
||||||
|
|
||||||
num= eval_num_suffix(arg, err, (char*) optp->name);
|
num= eval_num_suffix(arg, err, (char*) optp->name);
|
||||||
if (num > 0 && (ulonglong) num > (ulonglong) (ulong) optp->max_value &&
|
if (num > 0 && (ulonglong) num > (ulonglong) optp->max_value &&
|
||||||
optp->max_value) /* if max value is not set -> no upper limit */
|
optp->max_value) /* if max value is not set -> no upper limit */
|
||||||
num= (longlong) (ulong) optp->max_value;
|
num= (ulonglong) optp->max_value;
|
||||||
num= ((num - (longlong) optp->sub_size) / block_size);
|
num= ((num - optp->sub_size) / block_size);
|
||||||
num= (longlong) (num * block_size);
|
num= (longlong) (num * block_size);
|
||||||
return max(num, optp->min_value);
|
return max(num, optp->min_value);
|
||||||
}
|
}
|
||||||
|
@ -51,6 +51,8 @@ static unsigned int iter_count= 0;
|
|||||||
|
|
||||||
static const char *opt_basedir= "./";
|
static const char *opt_basedir= "./";
|
||||||
|
|
||||||
|
static longlong opt_getopt_ll_test= 0;
|
||||||
|
|
||||||
static int embedded_server_arg_count= 0;
|
static int embedded_server_arg_count= 0;
|
||||||
static char *embedded_server_args[MAX_SERVER_ARGS];
|
static char *embedded_server_args[MAX_SERVER_ARGS];
|
||||||
|
|
||||||
@ -11830,6 +11832,19 @@ static void test_bug11718()
|
|||||||
rc= mysql_query(mysql, "drop table t1, t2");
|
rc= mysql_query(mysql, "drop table t1, t2");
|
||||||
myquery(rc);
|
myquery(rc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
Bug #12925: Bad handling of maximum values in getopt
|
||||||
|
*/
|
||||||
|
static void test_bug12925()
|
||||||
|
{
|
||||||
|
myheader("test_bug12925");
|
||||||
|
if (opt_getopt_ll_test)
|
||||||
|
DIE_UNLESS(opt_getopt_ll_test == LL(25600*1024*1024));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Read and parse arguments and MySQL options from my.cnf
|
Read and parse arguments and MySQL options from my.cnf
|
||||||
*/
|
*/
|
||||||
@ -11872,6 +11887,9 @@ static struct my_option client_test_long_options[] =
|
|||||||
{"user", 'u', "User for login if not current user", (char **) &opt_user,
|
{"user", 'u', "User for login if not current user", (char **) &opt_user,
|
||||||
(char **) &opt_user, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
|
(char **) &opt_user, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
|
||||||
#endif
|
#endif
|
||||||
|
{"getopt-ll-test", 'g', "Option for testing bug in getopt library",
|
||||||
|
(char **) &opt_getopt_ll_test, (char **) &opt_getopt_ll_test, 0,
|
||||||
|
GET_LL, REQUIRED_ARG, 0, 0, LONGLONG_MAX, 0, 0, 0},
|
||||||
{ 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}
|
{ 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -12048,6 +12066,7 @@ static struct my_tests_st my_tests[]= {
|
|||||||
{ "test_bug11183", test_bug11183 },
|
{ "test_bug11183", test_bug11183 },
|
||||||
{ "test_bug12001", test_bug12001 },
|
{ "test_bug12001", test_bug12001 },
|
||||||
{ "test_bug11718", test_bug11718 },
|
{ "test_bug11718", test_bug11718 },
|
||||||
|
{ "test_bug12925", test_bug12925 },
|
||||||
{ 0, 0 }
|
{ 0, 0 }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user