Skip to content

Commit

Permalink
Mysqladmin crash with extended-status
Browse files Browse the repository at this point in the history
Summary:
The code hard codes fixed size array with max 512 while 5.6 returns 832 entries with SHOW STATUS. I've extended the max to be 8192 just to be on the safe side and added an error message if in mysql 100.0 happens to exceed that...

Reference Patch: facebook@8024dee

Reviewed By: lloyd

Differential Revision: D16836475
  • Loading branch information
yizhang82 authored and inikep committed Mar 4, 2023
1 parent bc36bd0 commit 4e75fad
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions client/mysqladmin.cc
Expand Up @@ -51,7 +51,7 @@
#include "typelib.h"
#include "welcome_copyright_notice.h" /* ORACLE_WELCOME_COPYRIGHT_NOTICE */

#define MAX_MYSQL_VAR 512
#define MAX_MYSQL_VAR 1024
#define SHUTDOWN_DEF_TIMEOUT 3600 /* Wait for shutdown */
#define MAX_TRUNC_LENGTH 3

Expand Down Expand Up @@ -876,7 +876,13 @@ static int execute_commands(MYSQL *mysql, int argc, char **argv) {
return -1;
}

assert(mysql_num_rows(res) < MAX_MYSQL_VAR);
if (mysql_num_rows(res) >= MAX_MYSQL_VAR) {
my_printf_error(0,
"Too many rows returned: '%lu'. "
"Expecting no more than '%d' rows",
error_flags, mysql_num_rows(res), MAX_MYSQL_VAR);
return -1;
}

if (!opt_vertical)
print_header(res);
Expand Down

0 comments on commit 4e75fad

Please sign in to comment.