summaryrefslogtreecommitdiff
path: root/main
diff options
context:
space:
mode:
authorCorey Farrell <git@cfware.com>2017-07-27 21:58:22 -0400
committerGeorge Joseph <gjoseph@digium.com>2017-08-01 15:46:00 -0600
commitcc1180ed949e2810b4a86c6dcd91431a33f6fa18 (patch)
tree60bdae0192a9be495d4dd566bc075b1c9aabde36 /main
parente92c1988ead53a84da4908d3e807f45a1cbd2b3d (diff)
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
Diffstat (limited to 'main')
-rw-r--r--main/Makefile3
-rw-r--r--main/ast_expr2.c6
-rw-r--r--main/ast_expr2.y6
-rw-r--r--main/asterisk.c7
-rw-r--r--main/ccss.c2
-rw-r--r--main/cli.c4
-rw-r--r--main/libasteriskssl.c24
-rw-r--r--main/manager.c2
-rw-r--r--main/stdtime/localtime.c2
-rw-r--r--main/utils.c2
10 files changed, 30 insertions, 28 deletions
diff --git a/main/Makefile b/main/Makefile
index 4fb6a0131..d816443d0 100644
--- a/main/Makefile
+++ b/main/Makefile
@@ -140,6 +140,7 @@ endif
$(CMD_PREFIX) rm $@.fix
ast_expr2f.o: _ASTCFLAGS+=-Wno-unused
+cdr.o: _ASTCFLAGS+=-Wno-format-truncation
testexpr2: ast_expr2f.c ast_expr2.c ast_expr2.h
$(CC) -g -c -Iinclude -DSTANDALONE ast_expr2f.c
@@ -314,7 +315,7 @@ endif
endif
-tcptls.o: _ASTCFLAGS+=$(OPENSSL_INCLUDE)
+tcptls.o: _ASTCFLAGS+=$(OPENSSL_INCLUDE) -Wno-deprecated-declarations
$(MAIN_TGT): $(OBJS) $(ASTSSL_LIB) $(ASTPJ_LIB) $(LIBEDIT_OBJ)
@$(CC) -c -o buildinfo.o $(_ASTCFLAGS) buildinfo.c $(ASTCFLAGS)
diff --git a/main/ast_expr2.c b/main/ast_expr2.c
index 215f8312f..d7c9ed33a 100644
--- a/main/ast_expr2.c
+++ b/main/ast_expr2.c
@@ -2638,13 +2638,11 @@ to_string (struct val *vp)
if (vp->type == AST_EXPR_string || vp->type == AST_EXPR_numeric_string)
return;
- tmp = malloc ((size_t)25);
- if (tmp == NULL) {
- ast_log(LOG_WARNING,"malloc() failed\n");
+ if (asprintf(&tmp, FP___PRINTF, vp->u.i) == -1) {
+ ast_log(LOG_WARNING, "asprintf() failed\n");
return;
}
- sprintf(tmp, FP___PRINTF, vp->u.i);
vp->type = AST_EXPR_string;
vp->u.s = tmp;
}
diff --git a/main/ast_expr2.y b/main/ast_expr2.y
index 8b32b2b9c..2ece15f29 100644
--- a/main/ast_expr2.y
+++ b/main/ast_expr2.y
@@ -631,13 +631,11 @@ to_string (struct val *vp)
if (vp->type == AST_EXPR_string || vp->type == AST_EXPR_numeric_string)
return;
- tmp = malloc ((size_t)25);
- if (tmp == NULL) {
- ast_log(LOG_WARNING,"malloc() failed\n");
+ if (asprintf(&tmp, FP___PRINTF, vp->u.i) == -1) {
+ ast_log(LOG_WARNING, "asprintf() failed\n");
return;
}
- sprintf(tmp, FP___PRINTF, vp->u.i);
vp->type = AST_EXPR_string;
vp->u.s = tmp;
}
diff --git a/main/asterisk.c b/main/asterisk.c
index 753ccf61d..1e4772ea7 100644
--- a/main/asterisk.c
+++ b/main/asterisk.c
@@ -394,6 +394,9 @@ static void ast_el_write_default_histfile(void);
static void asterisk_daemon(int isroot, const char *runuser, const char *rungroup);
+#define DEFAULT_MONITOR_DIR DEFAULT_SPOOL_DIR "/monitor"
+#define DEFAULT_RECORDING_DIR DEFAULT_SPOOL_DIR "/recording"
+
struct _cfg_paths {
char config_dir[PATH_MAX];
char module_dir[PATH_MAX];
@@ -3553,8 +3556,8 @@ static void ast_readconfig(void)
ast_copy_string(cfg_paths.config_dir, DEFAULT_CONFIG_DIR, sizeof(cfg_paths.config_dir));
ast_copy_string(cfg_paths.spool_dir, DEFAULT_SPOOL_DIR, sizeof(cfg_paths.spool_dir));
ast_copy_string(cfg_paths.module_dir, DEFAULT_MODULE_DIR, sizeof(cfg_paths.module_dir));
- snprintf(cfg_paths.monitor_dir, sizeof(cfg_paths.monitor_dir), "%s/monitor", cfg_paths.spool_dir);
- snprintf(cfg_paths.recording_dir, sizeof(cfg_paths.recording_dir), "%s/recording", cfg_paths.spool_dir);
+ ast_copy_string(cfg_paths.monitor_dir, DEFAULT_MONITOR_DIR, sizeof(cfg_paths.monitor_dir));
+ ast_copy_string(cfg_paths.recording_dir, DEFAULT_RECORDING_DIR, sizeof(cfg_paths.recording_dir));
ast_copy_string(cfg_paths.var_dir, DEFAULT_VAR_DIR, sizeof(cfg_paths.var_dir));
ast_copy_string(cfg_paths.data_dir, DEFAULT_DATA_DIR, sizeof(cfg_paths.data_dir));
ast_copy_string(cfg_paths.log_dir, DEFAULT_LOG_DIR, sizeof(cfg_paths.log_dir));
diff --git a/main/ccss.c b/main/ccss.c
index fb7318d5a..47f05a411 100644
--- a/main/ccss.c
+++ b/main/ccss.c
@@ -3552,7 +3552,7 @@ struct ast_cc_monitor *ast_cc_get_monitor_by_recall_core_id(const int core_id, c
*/
static void cc_unique_append(struct ast_str **str, const char *dialstring)
{
- char dialstring_search[AST_CHANNEL_NAME];
+ char dialstring_search[AST_CHANNEL_NAME + 1];
if (ast_strlen_zero(dialstring)) {
/* No dialstring to append. */
diff --git a/main/cli.c b/main/cli.c
index 26a2bac81..7c2ae1b31 100644
--- a/main/cli.c
+++ b/main/cli.c
@@ -373,7 +373,7 @@ static char *complete_number(const char *partial, unsigned int min, unsigned int
int i, count = 0;
unsigned int prospective[2];
unsigned int part = strtoul(partial, NULL, 10);
- char next[12];
+ char next[13];
if (part < min || part > max) {
return NULL;
@@ -1032,7 +1032,7 @@ static char *handle_chanlist(struct ast_cli_entry *e, int cmd, struct ast_cli_ar
it_chans = ao2_iterator_init(channels, 0);
for (; (msg = ao2_iterator_next(&it_chans)); ao2_ref(msg, -1)) {
struct ast_channel_snapshot *cs = stasis_message_data(msg);
- char durbuf[10] = "-";
+ char durbuf[16] = "-";
if (!count) {
if ((concise || verbose) && !ast_tvzero(cs->creationtime)) {
diff --git a/main/libasteriskssl.c b/main/libasteriskssl.c
index 292c98eaf..223a5d20b 100644
--- a/main/libasteriskssl.c
+++ b/main/libasteriskssl.c
@@ -31,20 +31,21 @@
ASTERISK_REGISTER_FILE()
+#include "asterisk/_private.h" /* ast_ssl_init() */
+
#ifdef HAVE_OPENSSL
#include <openssl/ssl.h>
#include <openssl/err.h>
#endif
-#include <dlfcn.h>
+#if defined(HAVE_OPENSSL) && \
+ !defined(OPENSSL_VERSION_NUMBER) || OPENSSL_VERSION_NUMBER < 0x10100000L || defined(LIBRESSL_VERSION_NUMBER)
-#include "asterisk/_private.h" /* ast_ssl_init() */
+#include <dlfcn.h>
#include "asterisk/utils.h"
#include "asterisk/lock.h"
-#ifdef HAVE_OPENSSL
-
#define get_OpenSSL_function(func) do { real_##func = dlsym(RTLD_NEXT, __stringify(func)); } while(0)
static int startup_complete;
@@ -74,7 +75,6 @@ static void ssl_lock(int mode, int n, const char *file, int line)
}
}
-#if !defined(OPENSSL_VERSION_NUMBER) || OPENSSL_VERSION_NUMBER < 0x10100000L || defined(LIBRESSL_VERSION_NUMBER)
int SSL_library_init(void)
{
#if defined(AST_DEVMODE)
@@ -116,9 +116,6 @@ void ERR_free_strings(void)
{
/* we can't allow this to be called, ever */
}
-#endif /* !defined(OPENSSL_VERSION_NUMBER) || OPENSSL_VERSION_NUMBER < 0x10100000L */
-
-#endif /* HAVE_OPENSSL */
/*!
* \internal
@@ -128,8 +125,6 @@ void ERR_free_strings(void)
*/
int ast_ssl_init(void)
{
-#if defined(HAVE_OPENSSL) && defined(OPENSSL_VERSION_NUMBER) && \
- (OPENSSL_VERSION_NUMBER < 0x10100000L || defined(LIBRESSL_VERSION_NUMBER))
unsigned int i;
int (*real_SSL_library_init)(void);
void (*real_CRYPTO_set_id_callback)(unsigned long (*)(void));
@@ -194,7 +189,14 @@ int ast_ssl_init(void)
startup_complete = 1;
-#endif /* HAVE_OPENSSL and its version < 1.1 */
return 0;
}
+#else
+
+int ast_ssl_init(void)
+{
+ return 0;
+}
+
+#endif
diff --git a/main/manager.c b/main/manager.c
index 80d9659ef..c5c75076c 100644
--- a/main/manager.c
+++ b/main/manager.c
@@ -6121,7 +6121,7 @@ static int action_coreshowchannels(struct mansession *s, const struct message *m
for (; (msg = ao2_iterator_next(&it_chans)); ao2_ref(msg, -1)) {
struct ast_channel_snapshot *cs = stasis_message_data(msg);
struct ast_str *built = ast_manager_build_channel_state_string_prefix(cs, "");
- char durbuf[10] = "";
+ char durbuf[16] = "";
if (!built) {
continue;
diff --git a/main/stdtime/localtime.c b/main/stdtime/localtime.c
index c946c5fa8..c370f47ab 100644
--- a/main/stdtime/localtime.c
+++ b/main/stdtime/localtime.c
@@ -2436,7 +2436,7 @@ static const char *store_by_locale(locale_t prevlocale)
cur = NULL;
AST_LIST_LOCK(&localelist);
for (x = 0; x < 10000; x++) {
- char name[5];
+ char name[6];
snprintf(name, sizeof(name), "%04d", x);
if (!find_by_name(name)) {
if ((cur = ast_calloc(1, sizeof(*cur) + strlen(name) + 1))) {
diff --git a/main/utils.c b/main/utils.c
index cfe2e4c42..781530f26 100644
--- a/main/utils.c
+++ b/main/utils.c
@@ -1525,7 +1525,7 @@ char *ast_strsep(char **iss, const char sep, uint32_t flags)
int found = 0;
char stack[8];
- if (iss == NULL || *iss == '\0') {
+ if (ast_strlen_zero(st)) {
return NULL;
}