<p>Jenkins2 <strong>merged</strong> this change.</p><p><a href="https://gerrit.asterisk.org/8936">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 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>31 files changed, 128 insertions(+), 64 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">diff --git a/addons/Makefile b/addons/Makefile<br>index 3d4045d..0c11bfc 100644<br>--- a/addons/Makefile<br>+++ b/addons/Makefile<br>@@ -65,6 +65,7 @@<br> format_mp3.so: mp3/common.o mp3/dct64_i386.o mp3/decode_ntom.o mp3/layer3.o mp3/tabinit.o mp3/interface.o<br> endif<br> <br>+chan_mobile.o: _ASTCFLAGS+=$(AST_NO_FORMAT_TRUNCATION)<br> chan_ooh323.o: _ASTCFLAGS+=$(H323CFLAGS)<br> chan_ooh323.so: _ASTCFLAGS+=$(H323CFLAGS)<br> chan_ooh323.so: $(addprefix ooh323c/src/,$(H323OBJS)) chan_ooh323.o ooh323cDriver.o<br>diff --git a/apps/Makefile b/apps/Makefile<br>index 13c77ab..3e3dc00 100644<br>--- a/apps/Makefile<br>+++ b/apps/Makefile<br>@@ -30,7 +30,11 @@<br> clean::<br> rm -f confbridge/*.o confbridge/*.i confbridge/*.gcda confbridge/*.gcno<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> app_confbridge.so: $(subst .c,.o,$(wildcard confbridge/*.c))<br> $(subst .c,.o,$(wildcard confbridge/*.c)): _ASTCFLAGS+=$(call MOD_ASTCFLAGS,app_confbridge)<br>diff --git a/apps/app_minivm.c b/apps/app_minivm.c<br>index a3dcef8..ef73cab 100644<br>--- a/apps/app_minivm.c<br>+++ b/apps/app_minivm.c<br>@@ -2788,11 +2788,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 b42eac2..f783ac9 100644<br>--- a/apps/app_queue.c<br>+++ b/apps/app_queue.c<br>@@ -6411,7 +6411,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 c3d8ccd..df84d2a 100644<br>--- a/apps/app_sms.c<br>+++ b/apps/app_sms.c<br>@@ -1207,7 +1207,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 a5494c5..6be1a07 100644<br>--- a/apps/app_test.c<br>+++ b/apps/app_test.c<br>@@ -332,7 +332,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>@@ -359,6 +358,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 86f2873..db65c12 100644<br>--- a/apps/app_voicemail.c<br>+++ b/apps/app_voicemail.c<br>@@ -1010,7 +1010,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>@@ -13167,7 +13167,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 6314279..49adb34 100644<br>--- a/channels/Makefile<br>+++ b/channels/Makefile<br>@@ -50,6 +50,9 @@<br> $(CHAN_DAHDI_OBJS): _ASTCFLAGS+=$(call MOD_ASTCFLAGS,chan_dahdi)<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> <br>diff --git a/channels/chan_dahdi.c b/channels/chan_dahdi.c<br>index 8669267..6870e67 100644<br>--- a/channels/chan_dahdi.c<br>+++ b/channels/chan_dahdi.c<br>@@ -1864,7 +1864,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 97cbe73..90d2316 100644<br>--- a/channels/chan_iax2.c<br>+++ b/channels/chan_iax2.c<br>@@ -14319,7 +14319,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 4e65c7b..b84d13f 100644<br>--- a/channels/chan_sip.c<br>+++ b/channels/chan_sip.c<br>@@ -35001,21 +35001,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>@@ -35043,7 +35044,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 97634bc..43cc32a 100644<br>--- a/channels/chan_skinny.c<br>+++ b/channels/chan_skinny.c<br>@@ -3709,49 +3709,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>@@ -6430,7 +6430,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>@@ -6452,7 +6451,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>@@ -7183,7 +7185,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>@@ -7205,7 +7206,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 c003a82..ec7226e 100644<br>--- a/channels/iax2/parser.c<br>+++ b/channels/iax2/parser.c<br>@@ -417,7 +417,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 ad6b9ab..0e6e871 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>@@ -18611,6 +18612,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 8d798a7..f8f9ca1 100644<br>--- a/configure.ac<br>+++ b/configure.ac<br>@@ -1277,6 +1277,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 1cb5bbe..da6d6f1 100644<br>--- a/main/config.c<br>+++ b/main/config.c<br>@@ -1738,7 +1738,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>@@ -1911,10 +1911,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 46bc440..0181454 100644<br>--- a/main/manager.c<br>+++ b/main/manager.c<br>@@ -7989,7 +7989,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 b4599de..bcfd42d 100644<br>--- a/main/pbx.c<br>+++ b/main/pbx.c<br>@@ -6165,7 +6165,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 5dc81f3..17a4d27 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 9ca0dfb..daa7d71 100644<br>--- a/pbx/dundi-parser.c<br>+++ b/pbx/dundi-parser.c<br>@@ -388,7 +388,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 7ec144d..93ff579 100644<br>--- a/pbx/pbx_dundi.c<br>+++ b/pbx/pbx_dundi.c<br>@@ -1239,7 +1239,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>@@ -1247,6 +1246,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 5a8f35a..4865883 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>@@ -95,5 +95,7 @@<br> res_stasis_recording.so: stasis_recording/stored.o<br> stasis_recording/stored.o: _ASTCFLAGS+=$(call MOD_ASTCFLAGS,res_stasis_recording)<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 e3935e0..b5505e6 100644<br>--- a/res/res_config_ldap.c<br>+++ b/res/res_config_ldap.c<br>@@ -1961,7 +1961,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], credentials[100] = "";<br>+ struct ast_str *buf;<br> int ctimesec = time(NULL) - connect_time;<br> <br> switch (cmd) {<br>@@ -1978,30 +1978,33 @@<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> if (ctimesec > 31536000) {<br>- ast_cli(a->fd, "%s%s for %d years, %d days, %d hours, %d minutes, %d seconds.\n",<br>- status, credentials, ctimesec / 31536000,<br>+ ast_cli(a->fd, "%s for %d years, %d days, %d hours, %d minutes, %d seconds.\n",<br>+ ast_str_buffer(buf), ctimesec / 31536000,<br> (ctimesec % 31536000) / 86400, (ctimesec % 86400) / 3600,<br> (ctimesec % 3600) / 60, ctimesec % 60);<br> } else if (ctimesec > 86400) {<br>- ast_cli(a->fd, "%s%s for %d days, %d hours, %d minutes, %d seconds.\n",<br>- status, credentials, ctimesec / 86400, (ctimesec % 86400) / 3600,<br>+ ast_cli(a->fd, "%s for %d days, %d hours, %d minutes, %d seconds.\n",<br>+ ast_str_buffer(buf), ctimesec / 86400, (ctimesec % 86400) / 3600,<br> (ctimesec % 3600) / 60, ctimesec % 60);<br> } else if (ctimesec > 3600) {<br>- ast_cli(a->fd, "%s%s for %d hours, %d minutes, %d seconds.\n",<br>- status, credentials, ctimesec / 3600, (ctimesec % 3600) / 60,<br>+ ast_cli(a->fd, "%s for %d hours, %d minutes, %d seconds.\n",<br>+ ast_str_buffer(buf), ctimesec / 3600, (ctimesec % 3600) / 60,<br> ctimesec % 60);<br> } else if (ctimesec > 60) {<br>- ast_cli(a->fd, "%s%s for %d minutes, %d seconds.\n", status, credentials,<br>+ ast_cli(a->fd, "%s for %d minutes, %d seconds.\n", ast_str_buffer(buf),<br> ctimesec / 60, ctimesec % 60);<br> } else {<br>- ast_cli(a->fd, "%s%s for %d seconds.\n", status, credentials, ctimesec);<br>+ ast_cli(a->fd, "%s for %d seconds.\n", ast_str_buffer(buf), ctimesec);<br> }<br> <br> return CLI_SUCCESS;<br>diff --git a/res/res_musiconhold.c b/res/res_musiconhold.c<br>index 17bcd90..4d98f60 100644<br>--- a/res/res_musiconhold.c<br>+++ b/res/res_musiconhold.c<br>@@ -1105,7 +1105,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/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 cabc268..0a3baec 100644<br>--- a/utils/Makefile<br>+++ b/utils/Makefile<br>@@ -157,7 +157,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 0c6ec03..6c83746 100644<br>--- a/utils/ael_main.c<br>+++ b/utils/ael_main.c<br>@@ -381,7 +381,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 2ea68b9..ec06868 100644<br>--- a/utils/astman.c<br>+++ b/utils/astman.c<br>@@ -543,14 +543,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 97cfaa9..2e77fb2 100644<br>--- a/utils/extconf.c<br>+++ b/utils/extconf.c<br>@@ -3180,7 +3180,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>@@ -3294,8 +3294,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/8936">change 8936</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/8936"/><meta itemprop="name" content="View Change"/></div></div>
<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: 13 </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: 8936 </div>
<div style="display:none"> Gerrit-PatchSet: 7 </div>
<div style="display:none"> Gerrit-Owner: 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>