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

----------------------------------------------------------------------------------------

mysqladmin: use PRIu64 to format a uint64_t variable (facebook#1208)

Summary:

Pull Request resolved: facebook#1208

Reviewed By: luqun

Differential Revision: D38956593

Pulled By: hermanlee

fbshipit-source-id: 86e6bf7
  • Loading branch information
yizhang82 authored and inikep committed May 15, 2023
1 parent c28829b commit 84e7cd5
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions client/mysqladmin.cc
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

// Maintenance of MySQL databases.

#include <cinttypes>
#include <fcntl.h>
#include <mysql.h>
#include <mysqld_error.h> /* to check server error codes */
Expand Down Expand Up @@ -51,7 +52,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 +877,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: '%" PRIu64 "'. "
"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 84e7cd5

Please sign in to comment.