bugfix: buffer overwrite in mariadb-backup

this fixes galera.galera_sst_mariabackup_table_options

Note that `man snprintf` says

  The functions snprintf() and vsnprintf() do not write more
  than size bytes (including the terminating null byte
  ('\0')). If the output was truncated due to this limit, then
  the return value is the number of characters (excluding the
  terminating null byte) which would have been written to the
  final string if enough space had been available.
This commit is contained in:
Sergei Golubchik 2024-05-04 21:02:53 +02:00
parent 349ca2be74
commit 983e6ca097

View file

@ -66,7 +66,7 @@ Street, Fifth Floor, Boston, MA 02110-1335 USA
#include "page0zip.h"
char *tool_name;
char tool_args[2048];
char tool_args[8192];
/* mysql flavor and version */
mysql_flavor_t server_flavor = FLAVOR_UNKNOWN;
@ -1937,9 +1937,11 @@ char *make_argv(char *buf, size_t len, int argc, char **argv)
if (strncmp(*argv, "--password", strlen("--password")) == 0) {
arg = "--password=...";
}
left-= snprintf(buf + len - left, left,
uint l= snprintf(buf + len - left, left,
"%s%c", arg, argc > 1 ? ' ' : 0);
++argv; --argc;
if (l < left)
left-= l;
}
return buf;