From 7c3cdc81f7c7397b545322e0215f3e93526469ca Mon Sep 17 00:00:00 2001 From: Corey Farrell Date: Thu, 27 Jul 2017 21:58:22 -0400 Subject: Fix compiler warnings on Fedora 26 / GCC 7. GCC 7 has added capability to produce warnings, this fixes most of those warnings. The specific warnings are disabled in a few places: * app_voicemail.c: truncation of paths more than 4096 chars in many places. * chan_mgcp.c: callid truncated to 80 chars. * cdr.c: two userfields are combined to cdr copy, fix would break ABI. * tcptls.c: ignore use of deprecated method SSLv3_client_method(). ASTERISK-27156 #close Change-Id: I65f280e7d3cfad279d16f41823a4d6fddcbc4c88 --- res/res_monitor.c | 41 ++++++++++++++++++++--------------------- 1 file changed, 20 insertions(+), 21 deletions(-) (limited to 'res/res_monitor.c') diff --git a/res/res_monitor.c b/res/res_monitor.c index 2ab52d873..fd3ff7a1c 100644 --- a/res/res_monitor.c +++ b/res/res_monitor.c @@ -457,7 +457,7 @@ int AST_OPTIONAL_API_NAME(ast_monitor_stop)(struct ast_channel *chan, int need_l LOCK_IF_NEEDED(chan, need_lock); if (ast_channel_monitor(chan)) { - char filename[ FILENAME_MAX ]; + RAII_VAR(struct ast_str *, tmp, ast_str_create(1024), ast_free); if (ast_channel_monitor(chan)->read_stream) { ast_closestream(ast_channel_monitor(chan)->read_stream); @@ -466,31 +466,29 @@ int AST_OPTIONAL_API_NAME(ast_monitor_stop)(struct ast_channel *chan, int need_l ast_closestream(ast_channel_monitor(chan)->write_stream); } - if (ast_channel_monitor(chan)->filename_changed && !ast_strlen_zero(ast_channel_monitor(chan)->filename_base)) { + if (tmp && ast_channel_monitor(chan)->filename_changed && !ast_strlen_zero(ast_channel_monitor(chan)->filename_base)) { if (ast_fileexists(ast_channel_monitor(chan)->read_filename,NULL,NULL) > 0) { - snprintf(filename, FILENAME_MAX, "%s-in", ast_channel_monitor(chan)->filename_base); - if (ast_fileexists(filename, NULL, NULL) > 0) { - ast_filedelete(filename, NULL); + ast_str_set(&tmp, 0, "%s-in", ast_channel_monitor(chan)->filename_base); + if (ast_fileexists(ast_str_buffer(tmp), NULL, NULL) > 0) { + ast_filedelete(ast_str_buffer(tmp), NULL); } - ast_filerename(ast_channel_monitor(chan)->read_filename, filename, ast_channel_monitor(chan)->format); + ast_filerename(ast_channel_monitor(chan)->read_filename, ast_str_buffer(tmp), ast_channel_monitor(chan)->format); } else { ast_log(LOG_WARNING, "File %s not found\n", ast_channel_monitor(chan)->read_filename); } - if (ast_fileexists(ast_channel_monitor(chan)->write_filename,NULL,NULL) > 0) { - snprintf(filename, FILENAME_MAX, "%s-out", ast_channel_monitor(chan)->filename_base); - if (ast_fileexists(filename, NULL, NULL) > 0) { - ast_filedelete(filename, NULL); + if (tmp && ast_fileexists(ast_channel_monitor(chan)->write_filename,NULL,NULL) > 0) { + ast_str_set(&tmp, 0, "%s-out", ast_channel_monitor(chan)->filename_base); + if (ast_fileexists(ast_str_buffer(tmp), NULL, NULL) > 0) { + ast_filedelete(ast_str_buffer(tmp), NULL); } - ast_filerename(ast_channel_monitor(chan)->write_filename, filename, ast_channel_monitor(chan)->format); + ast_filerename(ast_channel_monitor(chan)->write_filename, ast_str_buffer(tmp), ast_channel_monitor(chan)->format); } else { ast_log(LOG_WARNING, "File %s not found\n", ast_channel_monitor(chan)->write_filename); } } - if (ast_channel_monitor(chan)->joinfiles && !ast_strlen_zero(ast_channel_monitor(chan)->filename_base)) { - char tmp[1024]; - char tmp2[1024]; + if (tmp && ast_channel_monitor(chan)->joinfiles && !ast_strlen_zero(ast_channel_monitor(chan)->filename_base)) { const char *format = !strcasecmp(ast_channel_monitor(chan)->format,"wav49") ? "WAV" : ast_channel_monitor(chan)->format; char *fname_base = ast_channel_monitor(chan)->filename_base; const char *execute, *execute_args; @@ -511,16 +509,17 @@ int AST_OPTIONAL_API_NAME(ast_monitor_stop)(struct ast_channel *chan, int need_l if (ast_strlen_zero(execute_args)) { execute_args = ""; } - - snprintf(tmp, sizeof(tmp), "%s \"%s-in.%s\" \"%s-out.%s\" \"%s.%s\" %s &", + + ast_str_set(&tmp, 0, delfiles ? "( " : ""); + ast_str_append(&tmp, 0, "%s \"%s-in.%s\" \"%s-out.%s\" \"%s.%s\" %s &", execute, fname_base, format, fname_base, format, fname_base, format,execute_args); if (delfiles) { - snprintf(tmp2,sizeof(tmp2), "( %s& rm -f \"%s-\"* ) &",tmp, fname_base); /* remove legs when done mixing */ - ast_copy_string(tmp, tmp2, sizeof(tmp)); + /* remove legs when done mixing */ + ast_str_append(&tmp, 0, "& rm -f \"%s-\"* ) &", fname_base); } - ast_debug(1,"monitor executing %s\n",tmp); - if (ast_safe_system(tmp) == -1) - ast_log(LOG_WARNING, "Execute of %s failed.\n",tmp); + ast_debug(1,"monitor executing %s\n", ast_str_buffer(tmp)); + if (ast_safe_system(ast_str_buffer(tmp)) == -1) + ast_log(LOG_WARNING, "Execute of %s failed.\n", ast_str_buffer(tmp)); } if (!ast_strlen_zero(ast_channel_monitor(chan)->beep_id)) { -- cgit v1.2.3