Fix GCC 8 build issues.

This fixes build warnings found by GCC 8.  In some cases format
truncation is intentional so the warning is just suppressed.

ASTERISK-27824 #close

Change-Id: I724f146cbddba8b86619d4c4a9931ee877995c84
This commit is contained in:
Corey Farrell
2018-05-07 11:49:18 -04:00
parent a722e79434
commit d893e57c90
31 changed files with 128 additions and 64 deletions

View File

@@ -157,7 +157,7 @@ aelparse.c: $(ASTTOPDIR)/res/ael/ael_lex.c
$(CMD_PREFIX) sed 's/ast_debug([[:digit:]][[:digit:]]*/ast_log(LOG_DEBUG/' "$@" > "$@.new"
$(CMD_PREFIX) mv "$@.new" "$@"
aelparse.o: _ASTCFLAGS+=-I$(ASTTOPDIR)/res -Wno-unused
aelparse.o: _ASTCFLAGS+=-I$(ASTTOPDIR)/res -Wno-unused $(AST_NO_FORMAT_TRUNCATION)
aelparse: LIBS+=-lm $(AST_CLANG_BLOCKS_LIBS)
aelparse: aelparse.o aelbison.o pbx_ael.o hashtab.o lock.o ael_main.o ast_expr2f.o ast_expr2.o strcompat.o pval.o extconf.o

View File

@@ -381,7 +381,7 @@ void ast_context_add_switch2(struct ast_context *con, const char *value, const c
if( dump_extensions ) {
struct namelist *x;
x = create_name((char*)value);
strncpy(x->name2,data,100);
strncpy(x->name2, data, 99);
if( eval ) {
ADD_LAST(con->switches,x);

View File

@@ -543,14 +543,15 @@ static void try_redirect(newtComponent c)
struct ast_chan *chan;
char dest[256];
struct message *m;
static const char tmp_prefix[] = "Enter new extension for ";
char channame[256];
char tmp[80];
char tmp[sizeof(tmp_prefix) + sizeof(channame)];
char *context;
chan = newtListboxGetCurrent(c);
if (chan) {
strncpy(channame, chan->name, sizeof(channame) - 1);
snprintf(tmp, sizeof(tmp), "Enter new extension for %s", channame);
snprintf(tmp, sizeof(tmp), "%s%s", tmp_prefix, channame);
if (get_user_input(tmp, dest, sizeof(dest)))
return;
if ((context = strchr(dest, '@'))) {

View File

@@ -79,7 +79,7 @@ dbm_open(file, flags, mode)
info.cachesize = 0;
info.hash = NULL;
info.lorder = 0;
(void)strncpy(path, file, len - 1);
(void)strcpy(path, file); /* SAFE */
(void)strncat(path, DBM_SUFFIX, len - strlen(path) - 1);
db = (DBM *)__hash_open(path, flags, mode, &info, 0);
#ifndef __GNUC__

View File

@@ -3180,7 +3180,7 @@ static int process_text_line(struct ast_config *cfg, struct ast_category **cat,
char *c;
char *cur = buf;
struct ast_variable *v;
char cmd[512], exec_file[512];
char exec_file[512];
int object, do_exec, do_include;
/* Actually parse the entry */
@@ -3294,8 +3294,14 @@ static int process_text_line(struct ast_config *cfg, struct ast_category **cat,
/* #exec </path/to/executable>
We create a tmp file, then we #include it, then we delete it. */
if (do_exec) {
char cmd[1024];
snprintf(exec_file, sizeof(exec_file), "/var/tmp/exec.%d.%ld", (int)time(NULL), (long)pthread_self());
snprintf(cmd, sizeof(cmd), "%s > %s 2>&1", cur, exec_file);
if (snprintf(cmd, sizeof(cmd), "%s > %s 2>&1", cur, exec_file) >= sizeof(cmd)) {
ast_log(LOG_ERROR, "Failed to construct command string to execute %s.\n", cur);
return -1;
}
ast_safe_system(cmd);
cur = exec_file;
} else