Fix more GCC 8 build failures

Fixed string truncation warnings by reducing max parameter lengths by one
where applicable. The binlogrouter filename lengths are slightly different
so using memcpy to work around the warnings is an adequate "solution"
until the root of the problem is solved.

Removed unnecessary CMake policy settings from qc_sqlite. Adding a
self-dependency on the source file of an external project has no effect
and only caused warnings to be logged.
This commit is contained in:
Markus Mäkelä 2018-04-20 23:08:57 +03:00
parent 8829e6d0c5
commit d67320e06a
No known key found for this signature in database
GPG Key ID: 72D48FCE664F7B19
5 changed files with 9 additions and 13 deletions

View File

@ -1,7 +1,3 @@
if(NOT ${CMAKE_VERSION} VERSION_LESS 3.0.0)
cmake_policy(SET CMP0046 OLD)
endif()
include(ExternalProject)
ExternalProject_Add(maxscale_sqlite
@ -10,7 +6,6 @@ ExternalProject_Add(maxscale_sqlite
CONFIGURE_COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/sqlite-src-3110100/configure --with-pic --enable-maxscale
BUILD_COMMAND make sqlite3.c
INSTALL_COMMAND "")
add_dependencies(maxscale_sqlite ${CMAKE_CURRENT_SOURCE_DIR}/sqlite-src-3110100/src/parse.y)
include_directories(${CMAKE_BINARY_DIR}/sqlite-bld-3110100/tsrc)
include_directories(${CMAKE_BINARY_DIR}/sqlite-bld-3110100)

View File

@ -2537,7 +2537,8 @@ config_get_release_string(char* release)
}
have_distribution = true;
strncpy(release, new_to, RELEASE_STR_LENGTH);
strncpy(release, new_to, RELEASE_STR_LENGTH - 1);
release[RELEASE_STR_LENGTH - 1] = '\0';
}
}
}

View File

@ -46,12 +46,12 @@ typedef enum { MES_RC_FAIL, MES_RC_SUCCESS, MES_RC_TIMEOUT } skygw_mes_rc_t;
static const char* timestamp_formatstr = "%04d-%02d-%02d %02d:%02d:%02d ";
/** One for terminating '\0' */
static const size_t timestamp_len = (4 + 1 + 2 + 1 + 2 + 1 + 2 + 1 + 2 + 1 + 2 + 3 + 1) * sizeof(char);
static const size_t timestamp_len = (4 + 1 + 2 + 1 + 2 + 1 + 2 + 1 + 2 + 1 + 2 + 3 + 1 + 16) * sizeof(char);
static const char* timestamp_formatstr_hp = "%04d-%02d-%02d %02d:%02d:%02d.%03d ";
/** One for terminating '\0' */
static const size_t timestamp_len_hp = (4 + 1 + 2 + 1 + 2 + 1 + 2 + 1 + 2 + 1 + 2 + 1 + 3 + 3 + 1) * sizeof(
char);
static const size_t timestamp_len_hp = (4 + 1 + 2 + 1 + 2 + 1 + 2 + 1 + 2 + 1 + 2 + 1 + 3 + 3 + 1 + 16) *
sizeof(char);
struct skygw_thread_st
{

View File

@ -117,7 +117,7 @@ int ini_parse_file(FILE* file,
end = find_char_or_comment(start + 1, ']');
if (*end == ']') {
*end = '\0';
strncpy0(section, start + 1, sizeof(section));
strncpy0(section, start + 1, sizeof(section) - 1);
*prev_name = '\0';
}
else if (!error) {
@ -141,7 +141,7 @@ int ini_parse_file(FILE* file,
rstrip(value);
/* Valid name[=:]value pair found, call handler */
strncpy0(prev_name, name, sizeof(prev_name));
strncpy0(prev_name, name, sizeof(prev_name) - 1);
if (!handler(user, section, name, value) && !error)
error = lineno;
}

View File

@ -1669,7 +1669,7 @@ blr_file_next_exists(ROUTER_INSTANCE *router,
sprintf(buf, BINLOG_NAMEFMT, router->fileroot, filenum + 1);
sprintf(bigbuf, "%s/%s", router->binlogdir, buf);
// Set the new file name in the output
strncpy(next_file, buf, BINLOG_FNAMELEN);
memcpy(next_file, buf, BINLOG_FNAMELEN);
next_file[BINLOG_FNAMELEN] = '\0';
}
else
@ -1712,7 +1712,7 @@ blr_file_next_exists(ROUTER_INSTANCE *router,
result.gtid_elms.server_id,
result.file);
// Set the new file name in the output
strncpy(next_file, result.file, BINLOG_FNAMELEN);
memcpy(next_file, result.file, BINLOG_FNAMELEN);
next_file[BINLOG_FNAMELEN] = '\0';
MXS_DEBUG("The next Binlog file from GTID maps repo is [%s]",