Fix binlogrouter build failures with GCC 8

GCC 8 appears to have improved the snprintf truncation detection which
revealed problems in the binlogrouter.
This commit is contained in:
Markus Mäkelä
2018-04-17 21:55:47 +03:00
parent 3a1c2119fb
commit ad15f4d4be
3 changed files with 8 additions and 10 deletions

View File

@ -78,11 +78,11 @@ bool binlog_next_file_exists(const char* binlogdir, const char* binlog)
{
char buf[BLRM_BINLOG_NAME_STR_LEN + 1];
char filename[PATH_MAX + 1];
char next_file[BLRM_BINLOG_NAME_STR_LEN + 1];
char next_file[BLRM_BINLOG_NAME_STR_LEN + 1 + 20];
int offset = sptr - binlog;
memcpy(buf, binlog, offset);
buf[offset] = '\0';
sprintf(next_file, BINLOG_NAMEFMT, buf, filenum);
snprintf(next_file, sizeof(next_file), BINLOG_NAMEFMT, buf, filenum);
snprintf(filename, PATH_MAX, "%s/%s", binlogdir, next_file);
filename[PATH_MAX] = '\0';