summaryrefslogtreecommitdiff
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:39:25 -0600
commit7c3cdc81f7c7397b545322e0215f3e93526469ca (patch)
tree7a8a3241c2efab7425779ff5117d72f4da591696
parent1078d4f7f6cb0e68f135f96ebb43c2ea4c0f0905 (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
-rw-r--r--addons/chan_ooh323.c8
-rw-r--r--apps/Makefile2
-rw-r--r--apps/app_chanspy.c2
-rw-r--r--apps/app_followme.c2
-rw-r--r--apps/app_minivm.c2
-rw-r--r--apps/app_queue.c18
-rw-r--r--apps/app_voicemail.c4
-rw-r--r--channels/Makefile2
-rw-r--r--channels/chan_iax2.c2
-rw-r--r--channels/chan_motif.c2
-rw-r--r--channels/chan_sip.c6
-rw-r--r--channels/chan_unistim.c4
-rw-r--r--channels/iax2/firmware.c13
-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
-rw-r--r--res/res_calendar.c2
-rw-r--r--res/res_config_pgsql.c2
-rw-r--r--res/res_monitor.c41
-rw-r--r--utils/astman.c2
-rw-r--r--utils/extconf.c4
28 files changed, 94 insertions, 82 deletions
diff --git a/addons/chan_ooh323.c b/addons/chan_ooh323.c
index 2a895650a..0d5a588b7 100644
--- a/addons/chan_ooh323.c
+++ b/addons/chan_ooh323.c
@@ -3181,7 +3181,7 @@ int reload_config(int reload)
static char *handle_cli_ooh323_show_peer(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
{
- char ip_port[30];
+ char ip_port[64];
struct ooh323_peer *prev = NULL, *peer = NULL;
switch (cmd) {
@@ -3212,7 +3212,7 @@ static char *handle_cli_ooh323_show_peer(struct ast_cli_entry *e, int cmd, struc
}
if (peer) {
- sprintf(ip_port, "%s:%d", peer->ip, peer->port);
+ sprintf(ip_port, "%s:%hu", peer->ip, peer->port);
ast_cli(a->fd, "%-15.15s%s\n", "Name: ", peer->name);
ast_cli(a->fd, "%s:%s,%s\n", "FastStart/H.245 Tunneling", peer->faststart?"yes":"no",
peer->h245tunneling?"yes":"no");
@@ -3280,7 +3280,7 @@ static char *handle_cli_ooh323_show_peers(struct ast_cli_entry *e, int cmd, stru
{
struct ooh323_peer *prev = NULL, *peer = NULL;
struct ast_str *codec_buf = ast_str_alloca(AST_FORMAT_CAP_NAMES_LEN);
- char ip_port[30];
+ char ip_port[64];
#define FORMAT "%-15.15s %-15.15s %-23.23s %-s\n"
switch (cmd) {
@@ -3303,7 +3303,7 @@ static char *handle_cli_ooh323_show_peers(struct ast_cli_entry *e, int cmd, stru
peer = peerl.peers;
while (peer) {
ast_mutex_lock(&peer->lock);
- snprintf(ip_port, sizeof(ip_port), "%s:%d", peer->ip, peer->port);
+ snprintf(ip_port, sizeof(ip_port), "%s:%hu", peer->ip, peer->port);
ast_cli(a->fd, FORMAT, peer->name,
peer->accountcode,
ip_port,
diff --git a/apps/Makefile b/apps/Makefile
index 7730460fe..d68817350 100644
--- a/apps/Makefile
+++ b/apps/Makefile
@@ -29,6 +29,8 @@ include $(ASTTOPDIR)/Makefile.moddir_rules
$(call MOD_ADD_C,app_confbridge,$(wildcard confbridge/*.c))
+app_voicemail.o: _ASTCFLAGS+=-Wno-format-truncation
+
ifneq ($(findstring $(OSARCH), mingw32 cygwin ),)
LIBS+= -lres_ael_share.so -lres_monitor.so -lres_speech.so
LIBS+= -lres_smdi.so
diff --git a/apps/app_chanspy.c b/apps/app_chanspy.c
index 354b9ea7d..95ebace63 100644
--- a/apps/app_chanspy.c
+++ b/apps/app_chanspy.c
@@ -1442,7 +1442,7 @@ static int extenspy_exec(struct ast_channel *chan, const char *data)
static int dahdiscan_exec(struct ast_channel *chan, const char *data)
{
const char *spec = "DAHDI";
- struct ast_flags flags;
+ struct ast_flags flags = {0};
struct spy_dtmf_options user_options = {
.cycle = '#',
.volume = '\0',
diff --git a/apps/app_followme.c b/apps/app_followme.c
index 72afa3dd1..578118ad3 100644
--- a/apps/app_followme.c
+++ b/apps/app_followme.c
@@ -1558,7 +1558,7 @@ outrun:
}
if (!ast_strlen_zero(targs->namerecloc)) {
int ret;
- char fn[PATH_MAX];
+ char fn[PATH_MAX + sizeof(REC_FORMAT)];
snprintf(fn, sizeof(fn), "%s.%s", targs->namerecloc,
REC_FORMAT);
diff --git a/apps/app_minivm.c b/apps/app_minivm.c
index ff9ab340a..9359f82f3 100644
--- a/apps/app_minivm.c
+++ b/apps/app_minivm.c
@@ -2251,7 +2251,7 @@ static int minivm_greet_exec(struct ast_channel *chan, const char *data)
char ecodes[16] = "#";
char *tmpptr;
struct minivm_account *vmu;
- char *username = argv[0];
+ char *username;
if (ast_strlen_zero(data)) {
ast_log(LOG_ERROR, "Minivm needs at least an account argument \n");
diff --git a/apps/app_queue.c b/apps/app_queue.c
index f297dad8d..004d93a2e 100644
--- a/apps/app_queue.c
+++ b/apps/app_queue.c
@@ -6610,7 +6610,6 @@ static int try_calling(struct queue_ent *qe, struct ast_flags opts, char **opt_a
char oldexten[AST_MAX_EXTENSION]="";
char oldcontext[AST_MAX_CONTEXT]="";
char queuename[256]="";
- char interfacevar[256]="";
struct ast_channel *peer;
struct ast_channel *which;
struct callattempt *lpeer;
@@ -6811,6 +6810,7 @@ static int try_calling(struct queue_ent *qe, struct ast_flags opts, char **opt_a
}
} else { /* peer is valid */
RAII_VAR(struct ast_json *, blob, NULL, ast_json_unref);
+ RAII_VAR(struct ast_str *, interfacevar, ast_str_create(325), ast_free);
/* Ah ha! Someone answered within the desired timeframe. Of course after this
we will always return with -1 so that it is hung up properly after the
conversation. */
@@ -6924,20 +6924,20 @@ static int try_calling(struct queue_ent *qe, struct ast_flags opts, char **opt_a
ao2_lock(qe->parent);
/* if setinterfacevar is defined, make member variables available to the channel */
/* use pbx_builtin_setvar to set a load of variables with one call */
- if (qe->parent->setinterfacevar) {
- snprintf(interfacevar, sizeof(interfacevar), "MEMBERINTERFACE=%s,MEMBERNAME=%s,MEMBERCALLS=%d,MEMBERLASTCALL=%ld,MEMBERPENALTY=%d,MEMBERDYNAMIC=%d,MEMBERREALTIME=%d",
+ if (qe->parent->setinterfacevar && interfacevar) {
+ ast_str_set(&interfacevar, 0, "MEMBERINTERFACE=%s,MEMBERNAME=%s,MEMBERCALLS=%d,MEMBERLASTCALL=%ld,MEMBERPENALTY=%d,MEMBERDYNAMIC=%d,MEMBERREALTIME=%d",
member->interface, member->membername, member->calls, (long)member->lastcall, member->penalty, member->dynamic, member->realtime);
- pbx_builtin_setvar_multiple(qe->chan, interfacevar);
- pbx_builtin_setvar_multiple(peer, interfacevar);
+ pbx_builtin_setvar_multiple(qe->chan, ast_str_buffer(interfacevar));
+ pbx_builtin_setvar_multiple(peer, ast_str_buffer(interfacevar));
}
/* if setqueueentryvar is defined, make queue entry (i.e. the caller) variables available to the channel */
/* use pbx_builtin_setvar to set a load of variables with one call */
- if (qe->parent->setqueueentryvar) {
- snprintf(interfacevar, sizeof(interfacevar), "QEHOLDTIME=%ld,QEORIGINALPOS=%d",
+ if (qe->parent->setqueueentryvar && interfacevar) {
+ ast_str_set(&interfacevar, 0, "QEHOLDTIME=%ld,QEORIGINALPOS=%d",
(long) (time(NULL) - qe->start), qe->opos);
- pbx_builtin_setvar_multiple(qe->chan, interfacevar);
- pbx_builtin_setvar_multiple(peer, interfacevar);
+ pbx_builtin_setvar_multiple(qe->chan, ast_str_buffer(interfacevar));
+ pbx_builtin_setvar_multiple(peer, ast_str_buffer(interfacevar));
}
ao2_unlock(qe->parent);
diff --git a/apps/app_voicemail.c b/apps/app_voicemail.c
index 0a07cc103..5f8212859 100644
--- a/apps/app_voicemail.c
+++ b/apps/app_voicemail.c
@@ -7913,7 +7913,7 @@ static int vm_forwardoptions(struct ast_channel *chan, struct ast_vm_user *vmu,
*duration += prepend_duration;
msg_cat = ast_category_get(msg_cfg, "message", NULL);
- snprintf(duration_buf, 11, "%ld", *duration);
+ snprintf(duration_buf, sizeof(duration_buf), "%ld", *duration);
if (!ast_variable_update(msg_cat, "duration", duration_buf, NULL, 0)) {
ast_config_text_file_save(textfile, msg_cfg, "app_voicemail");
}
@@ -8685,7 +8685,7 @@ static int play_message_duration(struct ast_channel *chan, struct vm_state *vms,
static int play_message(struct ast_channel *chan, struct ast_vm_user *vmu, struct vm_state *vms)
{
int res = 0;
- char filename[256], *cid;
+ char filename[PATH_MAX], *cid;
const char *origtime, *context, *category, *duration, *flag;
struct ast_config *msg_cfg;
struct ast_flags config_flags = { CONFIG_FLAG_NOCACHE };
diff --git a/channels/Makefile b/channels/Makefile
index 44a0429a9..ae7107f7c 100644
--- a/channels/Makefile
+++ b/channels/Makefile
@@ -29,6 +29,8 @@ $(call MOD_ADD_C,chan_pjsip,$(wildcard pjsip/*.c))
$(call MOD_ADD_C,chan_dahdi,$(wildcard dahdi/*.c) sig_analog.c sig_pri.c sig_ss7.c)
$(call MOD_ADD_C,chan_misdn,misdn_config.c misdn/isdn_lib.c misdn/isdn_msg_parser.c)
+chan_mgcp.o: _ASTCFLAGS+=-Wno-format-truncation
+
chan_misdn.o: _ASTCFLAGS+=-Imisdn
misdn_config.o: _ASTCFLAGS+=-Imisdn
misdn/isdn_lib.o: _ASTCFLAGS+=-Wno-strict-aliasing
diff --git a/channels/chan_iax2.c b/channels/chan_iax2.c
index 5abb6c37f..490c4cea5 100644
--- a/channels/chan_iax2.c
+++ b/channels/chan_iax2.c
@@ -8545,7 +8545,7 @@ static int try_transfer(struct chan_iax2_pvt *pvt, struct iax_ies *ies)
{
int newcall = 0;
struct iax_ie_data ied;
- struct ast_sockaddr new;
+ struct ast_sockaddr new = { {0,} };
memset(&ied, 0, sizeof(ied));
if (!ast_sockaddr_isnull(&ies->apparent_addr)) {
diff --git a/channels/chan_motif.c b/channels/chan_motif.c
index 7d696e87d..210cf36c6 100644
--- a/channels/chan_motif.c
+++ b/channels/chan_motif.c
@@ -1901,7 +1901,7 @@ static struct ast_channel *jingle_request(const char *type, struct ast_format_ca
{
RAII_VAR(struct jingle_config *, cfg, ao2_global_obj_ref(globals), ao2_cleanup);
RAII_VAR(struct jingle_endpoint *, endpoint, NULL, ao2_cleanup);
- char *dialed, target[200] = "";
+ char *dialed, target[1024] = "";
struct ast_xmpp_buddy *buddy;
struct jingle_session *session;
struct ast_channel *chan;
diff --git a/channels/chan_sip.c b/channels/chan_sip.c
index f2daf2b8f..beaa3de0b 100644
--- a/channels/chan_sip.c
+++ b/channels/chan_sip.c
@@ -2085,7 +2085,7 @@ static int sip_cc_monitor_request_cc(struct ast_cc_monitor *monitor, int *availa
static int construct_pidf_body(enum sip_cc_publish_state state, char *pidf_body, size_t size, const char *presentity)
{
struct ast_str *body = ast_str_alloca(size);
- char tuple_id[32];
+ char tuple_id[64];
generate_random_string(tuple_id, sizeof(tuple_id));
@@ -15333,7 +15333,7 @@ static int transmit_cc_notify(struct ast_cc_agent *agent, struct sip_pvt *subscr
{
struct sip_request req;
struct sip_cc_agent_pvt *agent_pvt = agent->private_data;
- char uri[SIPBUFSIZE];
+ char uri[SIPBUFSIZE + sizeof("cc-URI: \r\n") - 1];
char state_str[64];
char subscription_state_hdr[64];
@@ -15350,7 +15350,7 @@ static int transmit_cc_notify(struct ast_cc_agent *agent, struct sip_pvt *subscr
add_header(&req, "Subscription-State", subscription_state_hdr);
if (state == CC_READY) {
generate_uri(subscription, agent_pvt->notify_uri, sizeof(agent_pvt->notify_uri));
- snprintf(uri, sizeof(uri) - 1, "cc-URI: %s\r\n", agent_pvt->notify_uri);
+ snprintf(uri, sizeof(uri), "cc-URI: %s\r\n", agent_pvt->notify_uri);
}
add_content(&req, state_str);
if (state == CC_READY) {
diff --git a/channels/chan_unistim.c b/channels/chan_unistim.c
index b820cf51e..f124c0f2b 100644
--- a/channels/chan_unistim.c
+++ b/channels/chan_unistim.c
@@ -370,7 +370,7 @@ struct unistim_subchannel {
struct unistim_line {
ast_mutex_t lock;
char name[80]; /*! Like 200 */
- char fullname[80]; /*! Like USTM/200\@black */
+ char fullname[101]; /*! Like USTM/200\@black */
char exten[AST_MAX_EXTENSION]; /*! Extension where to start */
char cid_num[AST_MAX_EXTENSION]; /*! CallerID Number */
char mailbox[AST_MAX_EXTENSION]; /*! Mailbox for MWI */
@@ -3698,7 +3698,7 @@ static void key_select_option(struct unistimsession *pte, char keycode)
#define SELECTCODEC_MSG "Codec number : .."
static void handle_select_codec(struct unistimsession *pte)
{
- char buf[30], buf2[5];
+ char buf[30], buf2[6];
pte->state = STATE_SELECTCODEC;
ast_copy_string(buf, ustmtext("Using codec", pte), sizeof(buf));
diff --git a/channels/iax2/firmware.c b/channels/iax2/firmware.c
index 00a9d9ebb..500cf8938 100644
--- a/channels/iax2/firmware.c
+++ b/channels/iax2/firmware.c
@@ -44,6 +44,8 @@
#include "include/firmware.h"
+#define IAX_FIRMWARE_SUBDIR "/firmware/iax"
+
struct iax_firmware {
AST_LIST_ENTRY(iax_firmware) list;
int fd;
@@ -206,7 +208,7 @@ void iax_firmware_reload(void)
struct iax_firmware *cur = NULL;
DIR *fwd;
struct dirent *de;
- char dir[256], fn[256];
+ char fn[PATH_MAX + sizeof(IAX_FIRMWARE_SUBDIR) + sizeof(de->d_name)];
AST_LIST_LOCK(&firmwares);
@@ -216,12 +218,13 @@ void iax_firmware_reload(void)
}
/* Now that we have marked them dead... load new ones */
- snprintf(dir, sizeof(dir), "%s/firmware/iax", ast_config_AST_DATA_DIR);
- fwd = opendir(dir);
+ snprintf(fn, sizeof(fn), "%s%s", ast_config_AST_DATA_DIR, IAX_FIRMWARE_SUBDIR);
+ fwd = opendir(fn);
if (fwd) {
while((de = readdir(fwd))) {
if (de->d_name[0] != '.') {
- snprintf(fn, sizeof(fn), "%s/%s", dir, de->d_name);
+ snprintf(fn, sizeof(fn), "%s%s/%s",
+ ast_config_AST_DATA_DIR, IAX_FIRMWARE_SUBDIR, de->d_name);
if (!try_firmware(fn)) {
ast_verb(2, "Loaded firmware '%s'\n", de->d_name);
}
@@ -229,7 +232,7 @@ void iax_firmware_reload(void)
}
closedir(fwd);
} else {
- ast_log(LOG_WARNING, "Error opening firmware directory '%s': %s\n", dir, strerror(errno));
+ ast_log(LOG_WARNING, "Error opening firmware directory '%s': %s\n", fn, strerror(errno));
}
/* Clean up leftovers */
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 4b06ffe91..093b441d0 100644
--- a/main/ast_expr2.c
+++ b/main/ast_expr2.c
@@ -2635,13 +2635,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 f516291f9..3c8943094 100644
--- a/main/ast_expr2.y
+++ b/main/ast_expr2.y
@@ -628,13 +628,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 a302836a4..0a131fda9 100644
--- a/main/asterisk.c
+++ b/main/asterisk.c
@@ -393,6 +393,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];
@@ -3526,8 +3529,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 f96d7aa1d..a9d15b072 100644
--- a/main/ccss.c
+++ b/main/ccss.c
@@ -3546,7 +3546,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 06f2d55b2..ef86e256a 100644
--- a/main/cli.c
+++ b/main/cli.c
@@ -372,7 +372,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;
@@ -1031,7 +1031,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 9da63de4c..8b19e247d 100644
--- a/main/libasteriskssl.c
+++ b/main/libasteriskssl.c
@@ -29,20 +29,21 @@
#include "asterisk.h"
+#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;
@@ -72,7 +73,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)
@@ -114,9 +114,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
@@ -126,8 +123,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));
@@ -192,7 +187,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 1bbd1bbe9..d16a69278 100644
--- a/main/manager.c
+++ b/main/manager.c
@@ -6115,7 +6115,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 bb221aebf..88b802028 100644
--- a/main/stdtime/localtime.c
+++ b/main/stdtime/localtime.c
@@ -2434,7 +2434,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 c254db520..f20ccd36e 100644
--- a/main/utils.c
+++ b/main/utils.c
@@ -1490,7 +1490,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;
}
diff --git a/res/res_calendar.c b/res/res_calendar.c
index 666b0e184..9ce8159c7 100644
--- a/res/res_calendar.c
+++ b/res/res_calendar.c
@@ -741,7 +741,7 @@ static void *do_notify(void *data)
struct ast_channel *chan = NULL;
struct ast_variable *itervar;
char *tech, *dest;
- char buf[8];
+ char buf[33];
struct ast_format_cap *caps;
tech = ast_strdupa(event->owner->notify_channel);
diff --git a/res/res_config_pgsql.c b/res/res_config_pgsql.c
index 536c9e173..7a2c9dbf8 100644
--- a/res/res_config_pgsql.c
+++ b/res/res_config_pgsql.c
@@ -1294,7 +1294,7 @@ static int require_pgsql(const char *database, const char *tablename, va_list ap
/* Size is minimum length; make it at least 50% greater,
* just to be sure, because PostgreSQL doesn't support
* resizing columns. */
- snprintf(fieldtype, sizeof(fieldtype), "CHAR(%d)",
+ snprintf(fieldtype, sizeof(fieldtype), "CHAR(%hhu)",
size < 15 ? size * 2 :
(size * 3 / 2 > 255) ? 255 : size * 3 / 2);
} else if (type == RQ_INTEGER1 || type == RQ_UINTEGER1 || type == RQ_INTEGER2) {
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)) {
diff --git a/utils/astman.c b/utils/astman.c
index 63d7f5ada..af3185104 100644
--- a/utils/astman.c
+++ b/utils/astman.c
@@ -275,7 +275,7 @@ static void rebuild_channels(newtComponent c)
{
void *prev = NULL;
struct ast_chan *chan;
- char tmpn[42];
+ char tmpn[sizeof(chan->name) + sizeof(chan->callerid) + 3 - 1];
char tmp[256];
int x=0;
prev = newtListboxGetCurrent(c);
diff --git a/utils/extconf.c b/utils/extconf.c
index d035e12c0..116302280 100644
--- a/utils/extconf.c
+++ b/utils/extconf.c
@@ -4605,6 +4605,10 @@ static struct ast_exten *pbx_find_extension(struct ast_channel *chan,
struct ast_exten *e, *eroot;
struct ast_include *i;
+ if (!context) {
+ return NULL;
+ }
+
/* Initialize status if appropriate */
if (q->stacklen == 0) {
q->status = STATUS_NO_CONTEXT;