<p>Jenkins2 <strong>merged</strong> this change.</p><p><a href="https://gerrit.asterisk.org/8935">View Change</a></p><div style="white-space:pre-wrap">Approvals:
Joshua Colp: Looks good to me, but someone else must approve
Matthew Fredrickson: Looks good to me, but someone else must approve
George Joseph: Looks good to me, approved
Jenkins2: Approved for Submit
</div><pre style="font-family: monospace,monospace; white-space: pre-wrap;">Fix GCC 8 build issues.<br><br>This fixes build warnings found by GCC 8. In some cases format<br>truncation is intentional so the warning is just suppressed.<br><br>ASTERISK-27824 #close<br><br>Change-Id: I724f146cbddba8b86619d4c4a9931ee877995c84<br>---<br>M addons/Makefile<br>M apps/Makefile<br>M apps/app_minivm.c<br>M apps/app_queue.c<br>M apps/app_sms.c<br>M apps/app_test.c<br>M apps/app_voicemail.c<br>M channels/Makefile<br>M channels/chan_dahdi.c<br>M channels/chan_iax2.c<br>M channels/chan_sip.c<br>M channels/chan_skinny.c<br>M channels/iax2/parser.c<br>M configure<br>M configure.ac<br>M funcs/Makefile<br>M main/config.c<br>M main/manager.c<br>M main/pbx.c<br>M makeopts.in<br>M pbx/dundi-parser.c<br>M pbx/pbx_dundi.c<br>M res/Makefile<br>M res/res_config_ldap.c<br>M res/res_musiconhold.c<br>M res/res_pjsip/pjsip_resolver.c<br>M tests/Makefile<br>M utils/Makefile<br>M utils/ael_main.c<br>M utils/astman.c<br>M utils/db1-ast/hash/ndbm.c<br>M utils/extconf.c<br>32 files changed, 135 insertions(+), 69 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">diff --git a/addons/Makefile b/addons/Makefile<br>index 47da132..866d34b 100644<br>--- a/addons/Makefile<br>+++ b/addons/Makefile<br>@@ -59,6 +59,7 @@<br> <br> include $(ASTTOPDIR)/Makefile.moddir_rules<br> <br>+chan_mobile.o: _ASTCFLAGS+=$(AST_NO_FORMAT_TRUNCATION)<br> chan_ooh323.so: _ASTCFLAGS+=$(H323CFLAGS)<br> $(call MOD_ADD_C,chan_ooh323,$(H323SOURCE))<br> <br>diff --git a/apps/Makefile b/apps/Makefile<br>index a53bbe2..589293c 100644<br>--- a/apps/Makefile<br>+++ b/apps/Makefile<br>@@ -29,7 +29,11 @@<br> <br> $(call MOD_ADD_C,app_confbridge,$(wildcard confbridge/*.c))<br> <br>+app_confbridge.o: _ASTCFLAGS+=$(AST_NO_FORMAT_TRUNCATION)<br>+app_meetme.o: _ASTCFLAGS+=$(AST_NO_FORMAT_TRUNCATION)<br>+app_minivm.o: _ASTCFLAGS+=$(AST_NO_FORMAT_TRUNCATION)<br> app_voicemail.o: _ASTCFLAGS+=$(AST_NO_FORMAT_TRUNCATION)<br>+app_while.o: _ASTCFLAGS+=$(AST_NO_FORMAT_TRUNCATION)<br> <br> ifneq ($(findstring $(OSARCH), mingw32 cygwin ),)<br> LIBS+= -lres_ael_share.so -lres_monitor.so -lres_speech.so<br>diff --git a/apps/app_minivm.c b/apps/app_minivm.c<br>index c09fba1..211acc1 100644<br>--- a/apps/app_minivm.c<br>+++ b/apps/app_minivm.c<br>@@ -2786,11 +2786,11 @@<br> switch (tmpwrite[1]) {<br> case 'n':<br> memmove(tmpwrite + len, tmpwrite + 2, strlen(tmpwrite + 2) + 1);<br>- strncpy(tmpwrite, "\n", len);<br>+ tmpwrite[0] = '\n';<br> break;<br> case 't':<br> memmove(tmpwrite + len, tmpwrite + 2, strlen(tmpwrite + 2) + 1);<br>- strncpy(tmpwrite, "\t", len);<br>+ tmpwrite[0] = '\t';<br> break;<br> default:<br> ast_log(LOG_NOTICE, "Substitution routine does not support this character: %c\n", tmpwrite[1]);<br>diff --git a/apps/app_queue.c b/apps/app_queue.c<br>index 1d7b036..c2962db 100644<br>--- a/apps/app_queue.c<br>+++ b/apps/app_queue.c<br>@@ -6540,7 +6540,7 @@<br> static void setup_mixmonitor(struct queue_ent *qe, const char *filename)<br> {<br> char escaped_filename[256];<br>- char file_with_ext[256];<br>+ char file_with_ext[sizeof(escaped_filename) + sizeof(qe->parent->monfmt)];<br> char mixmonargs[1512];<br> char escaped_monitor_exec[1024];<br> const char *monitor_options;<br>diff --git a/apps/app_sms.c b/apps/app_sms.c<br>index c50a686..0e37971 100644<br>--- a/apps/app_sms.c<br>+++ b/apps/app_sms.c<br>@@ -1214,7 +1214,7 @@<br> {<br> struct ast_tm tm;<br> struct timeval now = h->scts;<br>- char stm[9];<br>+ char stm[45];<br> <br> h->omsg[0] = 0x00; /* set later... */<br> h->omsg[1] = 0;<br>diff --git a/apps/app_test.c b/apps/app_test.c<br>index 7981dbd..9677270 100644<br>--- a/apps/app_test.c<br>+++ b/apps/app_test.c<br>@@ -330,7 +330,6 @@<br> {<br> int res = 0;<br> char testid[80]="";<br>- char fn[80];<br> FILE *f;<br> if (ast_channel_state(chan) != AST_STATE_UP)<br> res = ast_answer(chan);<br>@@ -357,6 +356,8 @@<br> if (strchr(testid, '/'))<br> res = -1;<br> if ((res >=0) && (!ast_strlen_zero(testid))) {<br>+ char fn[PATH_MAX];<br>+<br> /* Got a Test ID! Whoo hoo! */<br> /* Make the directory to hold the test results in case it's not there */<br> snprintf(fn, sizeof(fn), "%s/testresults", ast_config_AST_LOG_DIR);<br>diff --git a/apps/app_voicemail.c b/apps/app_voicemail.c<br>index ce6a54d..8d22cec 100644<br>--- a/apps/app_voicemail.c<br>+++ b/apps/app_voicemail.c<br>@@ -1008,7 +1008,7 @@<br> int old_new;<br> int old_old;<br> char *uniqueid;<br>- char mailbox[1];<br>+ char mailbox[0];<br> };<br> <br> struct mwi_sub_task {<br>@@ -13103,7 +13103,7 @@<br> struct mwi_sub *mwi_sub;<br> struct mwi_sub_task *p = datap;<br> <br>- len = sizeof(*mwi_sub);<br>+ len = sizeof(*mwi_sub) + 1;<br> if (!ast_strlen_zero(p->mailbox))<br> len += strlen(p->mailbox);<br> <br>diff --git a/channels/Makefile b/channels/Makefile<br>index 9f6f9d6..6398d95 100644<br>--- a/channels/Makefile<br>+++ b/channels/Makefile<br>@@ -30,6 +30,9 @@<br> $(call MOD_ADD_C,chan_misdn,misdn_config.c misdn/isdn_lib.c misdn/isdn_msg_parser.c)<br> <br> chan_mgcp.o: _ASTCFLAGS+=$(AST_NO_FORMAT_TRUNCATION)<br>+chan_unistim.o: _ASTCFLAGS+=$(AST_NO_FORMAT_TRUNCATION)<br>+chan_phone.o: _ASTCFLAGS+=$(AST_NO_FORMAT_TRUNCATION)<br>+chan_sip.o: _ASTCFLAGS+=$(AST_NO_FORMAT_TRUNCATION)<br> <br> chan_misdn.o: _ASTCFLAGS+=-Imisdn<br> misdn_config.o: _ASTCFLAGS+=-Imisdn<br>diff --git a/channels/chan_dahdi.c b/channels/chan_dahdi.c<br>index c149763..36f5deb 100644<br>--- a/channels/chan_dahdi.c<br>+++ b/channels/chan_dahdi.c<br>@@ -1787,7 +1787,7 @@<br> */<br> static void dahdi_ami_channel_event(struct dahdi_pvt *p, struct ast_channel *chan)<br> {<br>- char ch_name[20];<br>+ char ch_name[23];<br> <br> if (p->channel < CHAN_PSEUDO) {<br> /* No B channel */<br>diff --git a/channels/chan_iax2.c b/channels/chan_iax2.c<br>index 6c342a8..28282dc 100644<br>--- a/channels/chan_iax2.c<br>+++ b/channels/chan_iax2.c<br>@@ -14303,7 +14303,7 @@<br> static int iax2_exec(struct ast_channel *chan, const char *context, const char *exten, int priority, const char *callerid, const char *data)<br> {<br> char odata[256];<br>- char req[256];<br>+ char req[sizeof(odata) + AST_MAX_CONTEXT + AST_MAX_EXTENSION + sizeof("IAX2//@")];<br> char *ncontext;<br> struct iax2_dpcache *dp = NULL;<br> struct ast_app *dial = NULL;<br>diff --git a/channels/chan_sip.c b/channels/chan_sip.c<br>index bfdc5d0..ad06422 100644<br>--- a/channels/chan_sip.c<br>+++ b/channels/chan_sip.c<br>@@ -35038,21 +35038,22 @@<br> struct ast_str *overflow;<br> struct {<br> char **fragments;<br>+ size_t fragment_count;<br> char **expected;<br> int num_expected;<br> const char *description;<br> } tests[] = {<br>- { normal, normal, 1, "normal" },<br>- { fragmented, normal, 1, "fragmented" },<br>- { fragmented_body, normal, 1, "fragmented_body" },<br>- { multi_fragment, normal, 1, "multi_fragment" },<br>- { multi_message, multi_message_divided, 2, "multi_message" },<br>- { multi_message_body, multi_message_body_divided, 2, "multi_message_body" },<br>- { multi_message_in_fragments, multi_message_divided, 2, "multi_message_in_fragments" },<br>- { compact, compact, 1, "compact" },<br>- { faux, faux, 1, "faux" },<br>- { folded, folded, 1, "folded" },<br>- { cl_in_body, cl_in_body, 1, "cl_in_body" },<br>+ { normal, ARRAY_LEN(normal), normal, 1, "normal" },<br>+ { fragmented, ARRAY_LEN(fragmented), normal, 1, "fragmented" },<br>+ { fragmented_body, ARRAY_LEN(fragmented_body), normal, 1, "fragmented_body" },<br>+ { multi_fragment, ARRAY_LEN(multi_fragment), normal, 1, "multi_fragment" },<br>+ { multi_message, ARRAY_LEN(multi_message), multi_message_divided, 2, "multi_message" },<br>+ { multi_message_body, ARRAY_LEN(multi_message_body), multi_message_body_divided, 2, "multi_message_body" },<br>+ { multi_message_in_fragments, ARRAY_LEN(multi_message_in_fragments), multi_message_divided, 2, "multi_message_in_fragments" },<br>+ { compact, ARRAY_LEN(compact), compact, 1, "compact" },<br>+ { faux, ARRAY_LEN(faux), faux, 1, "faux" },<br>+ { folded, ARRAY_LEN(folded), folded, 1, "folded" },<br>+ { cl_in_body, ARRAY_LEN(cl_in_body), cl_in_body, 1, "cl_in_body" },<br> };<br> int i;<br> enum ast_test_result_state res = AST_TEST_PASS;<br>@@ -35080,7 +35081,7 @@<br> }<br> for (i = 0; i < ARRAY_LEN(tests); ++i) {<br> int num_messages = 0;<br>- if (mock_tcp_loop(tests[i].fragments, ARRAY_LEN(tests[i].fragments),<br>+ if (mock_tcp_loop(tests[i].fragments, tests[i].fragment_count,<br> &overflow, tests[i].expected, &num_messages, test)) {<br> ast_test_status_update(test, "Failed to parse message '%s'\n", tests[i].description);<br> res = AST_TEST_FAIL;<br>diff --git a/channels/chan_skinny.c b/channels/chan_skinny.c<br>index 0093a1f..2b13e5e 100644<br>--- a/channels/chan_skinny.c<br>+++ b/channels/chan_skinny.c<br>@@ -3706,49 +3706,49 @@<br> int posn = 0;<br> <br> ptr = dbgcli_buf;<br>- strncpy(ptr, "\0", 1);<br>+ ptr[0] = '\0';<br> if (skinnydebug & DEBUG_GENERAL) {<br>- strncpy(ptr, "general ", 8);<br>+ strcpy(ptr, "general "); /* SAFE */<br> posn += 8;<br> ptr += 8;<br> }<br> if (skinnydebug & DEBUG_SUB) {<br>- strncpy(ptr, "sub ", 4);<br>+ strcpy(ptr, "sub "); /* SAFE */<br> posn += 4;<br> ptr += 4;<br> }<br> if (skinnydebug & DEBUG_AUDIO) {<br>- strncpy(ptr, "audio ", 6);<br>+ strcpy(ptr, "audio "); /* SAFE */<br> posn += 6;<br> ptr += 6;<br> }<br> if (skinnydebug & DEBUG_PACKET) {<br>- strncpy(ptr, "packet ", 7);<br>+ strcpy(ptr, "packet "); /* SAFE */<br> posn += 7;<br> ptr += 7;<br> }<br> if (skinnydebug & DEBUG_LOCK) {<br>- strncpy(ptr, "lock ", 5);<br>+ strcpy(ptr, "lock "); /* SAFE */<br> posn += 5;<br> ptr += 5;<br> }<br> if (skinnydebug & DEBUG_TEMPLATE) {<br>- strncpy(ptr, "template ", 9);<br>+ strcpy(ptr, "template "); /* SAFE */<br> posn += 9;<br> ptr += 9;<br> }<br> if (skinnydebug & DEBUG_THREAD) {<br>- strncpy(ptr, "thread ", 7);<br>+ strcpy(ptr, "thread "); /* SAFE */<br> posn += 7;<br> ptr += 7;<br> }<br> if (skinnydebug & DEBUG_HINT) {<br>- strncpy(ptr, "hint ", 5);<br>+ strcpy(ptr, "hint "); /* SAFE */<br> posn += 5;<br> ptr += 5;<br> }<br> if (skinnydebug & DEBUG_KEEPALIVE) {<br>- strncpy(ptr, "keepalive ", 10);<br>+ strcpy(ptr, "keepalive "); /* SAFE */<br> posn += 10;<br> ptr += 10;<br> }<br>@@ -6427,7 +6427,6 @@<br> case STIMULUS_CALLPARK:<br> {<br> char extout[AST_MAX_EXTENSION];<br>- char message[32];<br> RAII_VAR(struct ast_bridge_channel *, bridge_channel, NULL, ao2_cleanup);<br> SKINNY_DEBUG(DEBUG_PACKET, 3, "Received STIMULUS_CALLPARK from %s, inst %d, callref %d\n",<br> d->name, instance, callreference);<br>@@ -6449,7 +6448,10 @@<br> }<br> <br> if (!ast_parking_park_call(bridge_channel, extout, sizeof(extout))) {<br>- snprintf(message, sizeof(message), "Call Parked at: %s", extout);<br>+ static const char msg_prefix[] = "Call Parked at: ";<br>+ char message[sizeof(msg_prefix) + sizeof(extout)];<br>+<br>+ snprintf(message, sizeof(message), "%s%s", msg_prefix, extout);<br> transmit_displaynotify(d, message, 10);<br> break;<br> }<br>@@ -7180,7 +7182,6 @@<br> case SOFTKEY_PARK:<br> {<br> char extout[AST_MAX_EXTENSION];<br>- char message[32];<br> RAII_VAR(struct ast_bridge_channel *, bridge_channel, NULL, ao2_cleanup);<br> SKINNY_DEBUG(DEBUG_PACKET, 3, "Received SOFTKEY_PARK from %s, inst %d, callref %d\n",<br> d->name, instance, callreference);<br>@@ -7202,7 +7203,10 @@<br> }<br> <br> if (!ast_parking_park_call(bridge_channel, extout, sizeof(extout))) {<br>- snprintf(message, sizeof(message), "Call Parked at: %s", extout);<br>+ static const char msg_prefix[] = "Call Parked at: ";<br>+ char message[sizeof(msg_prefix) + sizeof(extout)];<br>+<br>+ snprintf(message, sizeof(message), "%s%s", msg_prefix, extout);<br> transmit_displaynotify(d, message, 10);<br> break;<br> }<br>diff --git a/channels/iax2/parser.c b/channels/iax2/parser.c<br>index 8880b92..b94d306 100644<br>--- a/channels/iax2/parser.c<br>+++ b/channels/iax2/parser.c<br>@@ -415,7 +415,7 @@<br> int x;<br> int found;<br> char interp[1024];<br>- char tmp[1024];<br>+ char tmp[1046];<br> <br> if (len < 2)<br> return;<br>diff --git a/configure b/configure<br>index 1ec61d2..ac078ce 100755<br>--- a/configure<br>+++ b/configure<br>@@ -686,6 +686,7 @@<br> AST_RPATH<br> AST_NATIVE_ARCH<br> AST_SHADOW_WARNINGS<br>+AST_NO_STRINGOP_TRUNCATION<br> AST_NO_FORMAT_TRUNCATION<br> AST_NO_STRICT_OVERFLOW<br> AST_FORTIFY_SOURCE<br>@@ -18868,6 +18869,19 @@<br> fi<br> <br> <br>+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for -Wno-stringop-truncation" >&5<br>+$as_echo_n "checking for -Wno-stringop-truncation... " >&6; }<br>+if $(${CC} -Wno-stringop-truncation -Werror -S -o /dev/null -xc /dev/null > /dev/null 2>&1); then<br>+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5<br>+$as_echo "yes" >&6; }<br>+ AST_NO_STRINGOP_TRUNCATION=-Wno-stringop-truncation<br>+else<br>+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5<br>+$as_echo "no" >&6; }<br>+ AST_NO_STRINGOP_TRUNCATION=<br>+fi<br>+<br>+<br> { $as_echo "$as_me:${as_lineno-$LINENO}: checking for -Wshadow" >&5<br> $as_echo_n "checking for -Wshadow... " >&6; }<br> if $(${CC} -Wshadow -Werror -S -o /dev/null -xc /dev/null > /dev/null 2>&1); then<br>diff --git a/configure.ac b/configure.ac<br>index 1d8a834..f1c7ca8 100644<br>--- a/configure.ac<br>+++ b/configure.ac<br>@@ -1309,6 +1309,16 @@<br> fi<br> AC_SUBST(AST_NO_FORMAT_TRUNCATION)<br> <br>+AC_MSG_CHECKING(for -Wno-stringop-truncation)<br>+if $(${CC} -Wno-stringop-truncation -Werror -S -o /dev/null -xc /dev/null > /dev/null 2>&1); then<br>+ AC_MSG_RESULT(yes)<br>+ AST_NO_STRINGOP_TRUNCATION=-Wno-stringop-truncation<br>+else<br>+ AC_MSG_RESULT(no)<br>+ AST_NO_STRINGOP_TRUNCATION=<br>+fi<br>+AC_SUBST(AST_NO_STRINGOP_TRUNCATION)<br>+<br> AC_MSG_CHECKING(for -Wshadow)<br> if $(${CC} -Wshadow -Werror -S -o /dev/null -xc /dev/null > /dev/null 2>&1); then<br> AC_MSG_RESULT(yes)<br>diff --git a/funcs/Makefile b/funcs/Makefile<br>index 3f65070..40df635 100644<br>--- a/funcs/Makefile<br>+++ b/funcs/Makefile<br>@@ -25,3 +25,5 @@<br> # warning must be disabled; for safety reasons, SPRINTF() is kept in<br> # a separate module so that as little code as possible is left unchecked<br> func_sprintf.o: _ASTCFLAGS+=-Wno-format-nonliteral<br>+<br>+func_groupcount.o: _ASTCFLAGS+=$(AST_NO_FORMAT_TRUNCATION)<br>diff --git a/main/config.c b/main/config.c<br>index 2a16a34..978e124 100644<br>--- a/main/config.c<br>+++ b/main/config.c<br>@@ -1736,7 +1736,7 @@<br> char *c;<br> char *cur = buf;<br> struct ast_variable *v;<br>- char cmd[512], exec_file[512];<br>+ char exec_file[512];<br> <br> /* Actually parse the entry */<br> if (cur[0] == '[') { /* A category header */<br>@@ -1909,10 +1909,16 @@<br> We create a tmp file, then we #include it, then we delete it. */<br> if (!do_include) {<br> struct timeval now = ast_tvnow();<br>+ char cmd[1024];<br>+<br> if (!ast_test_flag(&flags, CONFIG_FLAG_NOCACHE))<br> config_cache_attribute(configfile, ATTRIBUTE_EXEC, NULL, who_asked);<br> snprintf(exec_file, sizeof(exec_file), "/var/tmp/exec.%d%d.%ld", (int)now.tv_sec, (int)now.tv_usec, (long)pthread_self());<br>- snprintf(cmd, sizeof(cmd), "%s > %s 2>&1", cur, exec_file);<br>+ if (snprintf(cmd, sizeof(cmd), "%s > %s 2>&1", cur, exec_file) >= sizeof(cmd)) {<br>+ ast_log(LOG_ERROR, "Failed to construct command string to execute %s.\n", cur);<br>+<br>+ return -1;<br>+ }<br> ast_safe_system(cmd);<br> cur = exec_file;<br> } else {<br>diff --git a/main/manager.c b/main/manager.c<br>index 0edc002..ff5588e 100644<br>--- a/main/manager.c<br>+++ b/main/manager.c<br>@@ -7998,7 +7998,8 @@<br> /* compute the expected response to compare with what we received */<br> {<br> char *a2;<br>- char a2_hash[256];<br>+ /* ast_md5_hash outputs 32 characters plus NULL terminator. */<br>+ char a2_hash[33];<br> char resp[256];<br> <br> /* XXX Now request method are hardcoded in A2 */<br>diff --git a/main/pbx.c b/main/pbx.c<br>index 70e72fe..727018b 100644<br>--- a/main/pbx.c<br>+++ b/main/pbx.c<br>@@ -6235,7 +6235,7 @@<br> char *last_presence_message;<br> <br> AST_LIST_ENTRY(store_hint) list;<br>- char data[1];<br>+ char data[0];<br> };<br> <br> AST_LIST_HEAD_NOLOCK(store_hints, store_hint);<br>diff --git a/makeopts.in b/makeopts.in<br>index 9caf322..44c2810 100644<br>--- a/makeopts.in<br>+++ b/makeopts.in<br>@@ -119,6 +119,7 @@<br> AST_TRAMPOLINES=@AST_TRAMPOLINES@<br> AST_NO_STRICT_OVERFLOW=@AST_NO_STRICT_OVERFLOW@<br> AST_NO_FORMAT_TRUNCATION=@AST_NO_FORMAT_TRUNCATION@<br>+AST_NO_STRINGOP_TRUNCATION=@AST_NO_STRINGOP_TRUNCATION@<br> AST_SHADOW_WARNINGS=@AST_SHADOW_WARNINGS@<br> AST_NESTED_FUNCTIONS=@AST_NESTED_FUNCTIONS@<br> AST_CLANG_BLOCKS=@AST_CLANG_BLOCKS@<br>diff --git a/pbx/dundi-parser.c b/pbx/dundi-parser.c<br>index 856f4ae..808559c 100644<br>--- a/pbx/dundi-parser.c<br>+++ b/pbx/dundi-parser.c<br>@@ -386,7 +386,7 @@<br> int x;<br> int found;<br> char interp[1024];<br>- char tmp[1024];<br>+ char tmp[1051];<br> if (len < 2)<br> return;<br> while(len >= 2) {<br>diff --git a/pbx/pbx_dundi.c b/pbx/pbx_dundi.c<br>index e0aeb49..d80f660 100644<br>--- a/pbx/pbx_dundi.c<br>+++ b/pbx/pbx_dundi.c<br>@@ -1237,7 +1237,6 @@<br> <br> static int cache_lookup(struct dundi_request *req, dundi_eid *peer_eid, uint32_t crc, int *lowexpiration)<br> {<br>- char key[256];<br> char eid_str[20];<br> char eidroot_str[20];<br> time_t now;<br>@@ -1245,6 +1244,8 @@<br> int res2=0;<br> char eid_str_full[20];<br> char tmp[256]="";<br>+ /* Enough space for largest value that can be stored in key. */<br>+ char key[sizeof(eid_str) + sizeof(tmp) + sizeof(req->dcontext) + sizeof(eidroot_str) + sizeof("hint////r")];<br> int x;<br> <br> time(&now);<br>diff --git a/res/Makefile b/res/Makefile<br>index ec3417b..5ff38ad 100644<br>--- a/res/Makefile<br>+++ b/res/Makefile<br>@@ -29,7 +29,7 @@<br> res_config_ldap.o: _ASTCFLAGS+=-DLDAP_DEPRECATED<br> <br> ael/ael_lex.o: ael/ael_lex.c ../include/asterisk/ael_structs.h ael/ael.tab.h<br>-ael/ael_lex.o: _ASTCFLAGS+=-I. -Iael -Wno-unused<br>+ael/ael_lex.o: _ASTCFLAGS+=-I. -Iael -Wno-unused $(AST_NO_FORMAT_TRUNCATION)<br> <br> ael/ael.tab.o: ael/ael.tab.c ael/ael.tab.h ../include/asterisk/ael_structs.h<br> ael/ael.tab.o: _ASTCFLAGS+=-I. -Iael -DYYENABLE_NLS=0<br>@@ -70,5 +70,7 @@<br> $(call MOD_ADD_C,res_ari_model,ari/ari_model_validators.c)<br> $(call MOD_ADD_C,res_stasis_recording,stasis_recording/stored.c)<br> <br>+res_parking.o: _ASTCFLAGS+=$(AST_NO_FORMAT_TRUNCATION)<br>+<br> # Dependencies for res_ari_*.so are generated, so they're in this file<br> include ari.make<br>diff --git a/res/res_config_ldap.c b/res/res_config_ldap.c<br>index 15d9ec0..2e862b7 100644<br>--- a/res/res_config_ldap.c<br>+++ b/res/res_config_ldap.c<br>@@ -1959,9 +1959,7 @@<br> */<br> static char *realtime_ldap_status(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)<br> {<br>- char status[256];<br>- char credentials[100] = "";<br>- char buf[362]; /* 256+100+" for "+NULL */<br>+ struct ast_str *buf;<br> int ctimesec = time(NULL) - connect_time;<br> <br> switch (cmd) {<br>@@ -1978,14 +1976,18 @@<br> if (!ldapConn)<br> return CLI_FAILURE;<br> <br>- if (!ast_strlen_zero(url))<br>- snprintf(status, sizeof(status), "Connected to '%s', baseDN %s", url, base_distinguished_name);<br>+ buf = ast_str_create(512);<br>+ if (!ast_strlen_zero(url)) {<br>+ ast_str_append(&buf, 0, "Connected to '%s', baseDN %s", url, base_distinguished_name);<br>+ }<br> <br>- if (!ast_strlen_zero(user))<br>- snprintf(credentials, sizeof(credentials), " with username %s", user);<br>+ if (!ast_strlen_zero(user)) {<br>+ ast_str_append(&buf, 0, " with username %s", user);<br>+ }<br> <br>- snprintf(buf, sizeof(buf), "%s%s for ", status, credentials);<br>- ast_cli_print_timestr_fromseconds(a->fd, ctimesec, buf);<br>+ ast_str_append(&buf, 0, " for ");<br>+ ast_cli_print_timestr_fromseconds(a->fd, ctimesec, ast_str_buffer(buf));<br>+ ast_free(buf);<br> <br> return CLI_SUCCESS;<br> }<br>diff --git a/res/res_musiconhold.c b/res/res_musiconhold.c<br>index 1c8728c..137f83b 100644<br>--- a/res/res_musiconhold.c<br>+++ b/res/res_musiconhold.c<br>@@ -1142,7 +1142,7 @@<br> <br> DIR *files_DIR;<br> struct dirent *files_dirent;<br>- char dir_path[PATH_MAX];<br>+ char dir_path[PATH_MAX - sizeof(class->dir)];<br> char filepath[PATH_MAX];<br> char *ext;<br> struct stat statbuf;<br>diff --git a/res/res_pjsip/pjsip_resolver.c b/res/res_pjsip/pjsip_resolver.c<br>index d6646d5..5fd4464 100644<br>--- a/res/res_pjsip/pjsip_resolver.c<br>+++ b/res/res_pjsip/pjsip_resolver.c<br>@@ -566,23 +566,26 @@<br> if (type == PJSIP_TRANSPORT_UNSPECIFIED ||<br> (type == PJSIP_TRANSPORT_TLS && sip_transport_is_available(PJSIP_TRANSPORT_TLS)) ||<br> (type == PJSIP_TRANSPORT_TLS6 && sip_transport_is_available(PJSIP_TRANSPORT_TLS6))) {<br>- snprintf(srv, sizeof(srv), "_sips._tcp.%s", host);<br>- res |= sip_resolve_add(resolve, srv, T_SRV, C_IN,<br>- type == PJSIP_TRANSPORT_UNSPECIFIED ? PJSIP_TRANSPORT_TLS : type, 0);<br>+ if (snprintf(srv, sizeof(srv), "_sips._tcp.%s", host) < NI_MAXHOST) {<br>+ res |= sip_resolve_add(resolve, srv, T_SRV, C_IN,<br>+ type == PJSIP_TRANSPORT_UNSPECIFIED ? PJSIP_TRANSPORT_TLS : type, 0);<br>+ }<br> }<br> if (type == PJSIP_TRANSPORT_UNSPECIFIED ||<br> (type == PJSIP_TRANSPORT_TCP && sip_transport_is_available(PJSIP_TRANSPORT_TCP)) ||<br> (type == PJSIP_TRANSPORT_TCP6 && sip_transport_is_available(PJSIP_TRANSPORT_TCP6))) {<br>- snprintf(srv, sizeof(srv), "_sip._tcp.%s", host);<br>- res |= sip_resolve_add(resolve, srv, T_SRV, C_IN,<br>- type == PJSIP_TRANSPORT_UNSPECIFIED ? PJSIP_TRANSPORT_TCP : type, 0);<br>+ if (snprintf(srv, sizeof(srv), "_sip._tcp.%s", host) < NI_MAXHOST) {<br>+ res |= sip_resolve_add(resolve, srv, T_SRV, C_IN,<br>+ type == PJSIP_TRANSPORT_UNSPECIFIED ? PJSIP_TRANSPORT_TCP : type, 0);<br>+ }<br> }<br> if (type == PJSIP_TRANSPORT_UNSPECIFIED ||<br> (type == PJSIP_TRANSPORT_UDP && sip_transport_is_available(PJSIP_TRANSPORT_UDP)) ||<br> (type == PJSIP_TRANSPORT_UDP6 && sip_transport_is_available(PJSIP_TRANSPORT_UDP6))) {<br>- snprintf(srv, sizeof(srv), "_sip._udp.%s", host);<br>- res |= sip_resolve_add(resolve, srv, T_SRV, C_IN,<br>- type == PJSIP_TRANSPORT_UNSPECIFIED ? PJSIP_TRANSPORT_UDP : type, 0);<br>+ if (snprintf(srv, sizeof(srv), "_sip._udp.%s", host) < NI_MAXHOST) {<br>+ res |= sip_resolve_add(resolve, srv, T_SRV, C_IN,<br>+ type == PJSIP_TRANSPORT_UNSPECIFIED ? PJSIP_TRANSPORT_UDP : type, 0);<br>+ }<br> }<br> }<br> <br>diff --git a/tests/Makefile b/tests/Makefile<br>index a65b88b..f64669b 100644<br>--- a/tests/Makefile<br>+++ b/tests/Makefile<br>@@ -18,3 +18,6 @@<br> all: _all<br> <br> include $(ASTTOPDIR)/Makefile.moddir_rules<br>+<br>+test_strings.o: _ASTCFLAGS+=$(AST_NO_FORMAT_TRUNCATION) $(AST_NO_STRINGOP_TRUNCATION)<br>+test_voicemail_api.o: _ASTCFLAGS+=$(AST_NO_FORMAT_TRUNCATION)<br>diff --git a/utils/Makefile b/utils/Makefile<br>index 1af90a4..9e7b08b 100644<br>--- a/utils/Makefile<br>+++ b/utils/Makefile<br>@@ -160,7 +160,7 @@<br> $(CMD_PREFIX) sed 's/ast_debug([[:digit:]][[:digit:]]*/ast_log(LOG_DEBUG/' "$@" > "$@.new"<br> $(CMD_PREFIX) mv "$@.new" "$@"<br> <br>-aelparse.o: _ASTCFLAGS+=-I$(ASTTOPDIR)/res -Wno-unused<br>+aelparse.o: _ASTCFLAGS+=-I$(ASTTOPDIR)/res -Wno-unused $(AST_NO_FORMAT_TRUNCATION)<br> aelparse: LIBS+=-lm $(AST_CLANG_BLOCKS_LIBS)<br> 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<br> <br>diff --git a/utils/ael_main.c b/utils/ael_main.c<br>index f22e9a0..3bfee48 100644<br>--- a/utils/ael_main.c<br>+++ b/utils/ael_main.c<br>@@ -373,7 +373,7 @@<br> if( dump_extensions ) {<br> struct namelist *x;<br> x = create_name((char*)value);<br>- strncpy(x->name2,data,100);<br>+ strncpy(x->name2, data, 99);<br> if( eval ) {<br> <br> ADD_LAST(con->switches,x);<br>diff --git a/utils/astman.c b/utils/astman.c<br>index af31851..81ff3a9 100644<br>--- a/utils/astman.c<br>+++ b/utils/astman.c<br>@@ -529,14 +529,15 @@<br> struct ast_chan *chan;<br> char dest[256];<br> struct message *m;<br>+ static const char tmp_prefix[] = "Enter new extension for ";<br> char channame[256];<br>- char tmp[80];<br>+ char tmp[sizeof(tmp_prefix) + sizeof(channame)];<br> char *context;<br> <br> chan = newtListboxGetCurrent(c);<br> if (chan) {<br> strncpy(channame, chan->name, sizeof(channame) - 1);<br>- snprintf(tmp, sizeof(tmp), "Enter new extension for %s", channame);<br>+ snprintf(tmp, sizeof(tmp), "%s%s", tmp_prefix, channame);<br> if (get_user_input(tmp, dest, sizeof(dest)))<br> return;<br> if ((context = strchr(dest, '@'))) {<br>diff --git a/utils/db1-ast/hash/ndbm.c b/utils/db1-ast/hash/ndbm.c<br>index d702f73..16202ed 100644<br>--- a/utils/db1-ast/hash/ndbm.c<br>+++ b/utils/db1-ast/hash/ndbm.c<br>@@ -79,7 +79,7 @@<br> info.cachesize = 0;<br> info.hash = NULL;<br> info.lorder = 0;<br>- (void)strncpy(path, file, len - 1);<br>+ (void)strcpy(path, file); /* SAFE */<br> (void)strncat(path, DBM_SUFFIX, len - strlen(path) - 1);<br> db = (DBM *)__hash_open(path, flags, mode, &info, 0);<br> #ifndef __GNUC__<br>diff --git a/utils/extconf.c b/utils/extconf.c<br>index 5b3a95b..53f0be5 100644<br>--- a/utils/extconf.c<br>+++ b/utils/extconf.c<br>@@ -3144,7 +3144,7 @@<br> char *c;<br> char *cur = buf;<br> struct ast_variable *v;<br>- char cmd[512], exec_file[512];<br>+ char exec_file[512];<br> int object, do_exec, do_include;<br> <br> /* Actually parse the entry */<br>@@ -3258,8 +3258,14 @@<br> /* #exec </path/to/executable><br> We create a tmp file, then we #include it, then we delete it. */<br> if (do_exec) {<br>+ char cmd[1024];<br>+<br> snprintf(exec_file, sizeof(exec_file), "/var/tmp/exec.%d.%ld", (int)time(NULL), (long)pthread_self());<br>- snprintf(cmd, sizeof(cmd), "%s > %s 2>&1", cur, exec_file);<br>+ if (snprintf(cmd, sizeof(cmd), "%s > %s 2>&1", cur, exec_file) >= sizeof(cmd)) {<br>+ ast_log(LOG_ERROR, "Failed to construct command string to execute %s.\n", cur);<br>+<br>+ return -1;<br>+ }<br> ast_safe_system(cmd);<br> cur = exec_file;<br> } else<br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/8935">change 8935</a>. To unsubscribe, visit <a href="https://gerrit.asterisk.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.asterisk.org/8935"/><meta itemprop="name" content="View Change"/></div></div>
<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: 15 </div>
<div style="display:none"> Gerrit-MessageType: merged </div>
<div style="display:none"> Gerrit-Change-Id: I724f146cbddba8b86619d4c4a9931ee877995c84 </div>
<div style="display:none"> Gerrit-Change-Number: 8935 </div>
<div style="display:none"> Gerrit-PatchSet: 5 </div>
<div style="display:none"> Gerrit-Owner: Corey Farrell <git@cfware.com> </div>
<div style="display:none"> Gerrit-Reviewer: Corey Farrell <git@cfware.com> </div>
<div style="display:none"> Gerrit-Reviewer: George Joseph <gjoseph@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: Jenkins2 </div>
<div style="display:none"> Gerrit-Reviewer: Joshua Colp <jcolp@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: Matthew Fredrickson <creslin@digium.com> </div>