Skip to content

Commit bf681d6

Browse files
author
Shishir Jaiswal
committed
Bug #20802751 - SEGMENTATION FAILURE WHEN RUNNING
MYSQLADMIN -U ROOT -P DESCRIPTION =========== Crash occurs when no command is given while executing mysqladmin utility. ANALYSIS ======== In mask_password() the final write to array 'temp_argv' is done without checking if corresponding index 'argc' is valid (non-negative) or not. In case its negative (would happen when this function is called with 'argc'=0), it may cause a SEGFAULT. Logically in such a case, mask_password() should not have been called as it would do no valid thing. FIX === mask_password() is now called after checking 'argc'. This function is now called only when 'argc' is positive otherwise the process terminates
1 parent 359f102 commit bf681d6

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

client/mysqladmin.cc

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.
2+
Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
33
44
This program is free software; you can redistribute it and/or modify
55
it under the terms of the GNU General Public License as published by
@@ -319,8 +319,6 @@ int main(int argc,char *argv[])
319319
free_defaults(save_argv);
320320
exit(ho_error);
321321
}
322-
temp_argv= mask_password(argc, &argv);
323-
temp_argc= argc;
324322

325323
if (debug_info_flag)
326324
my_end_arg= MY_CHECK_ERROR | MY_GIVE_INFO;
@@ -332,6 +330,10 @@ int main(int argc,char *argv[])
332330
usage();
333331
exit(1);
334332
}
333+
334+
temp_argv= mask_password(argc, &argv);
335+
temp_argc= argc;
336+
335337
commands = temp_argv;
336338
if (tty_password)
337339
opt_password = get_tty_password(NullS);

0 commit comments

Comments
 (0)