<p>Kevin Harwell has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.asterisk.org/c/asterisk/+/14456">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">Compiler fixes for gcc 10<br><br>This patch fixes a few compile warnings/errors that now occur when using gcc<br>10+.<br><br>Also, the Makefile.rules check to turn off partial inlining in gcc versions<br>greater or equal to 8.2.1 had a bug where it only it only checked against<br>versions with at least 3 numbers (ex: 8.2.1 vs 10). This patch now ensures<br>any version above the specified version is correctly compared.<br><br>Change-Id: I54718496eb0c3ce5bd6d427cd279a29e8d2825f9<br>---<br>M Makefile.rules<br>M addons/ooh323c/src/decode.c<br>M addons/ooh323c/src/ooSocket.c<br>M addons/ooh323c/src/oochannels.c<br>M apps/app_stack.c<br>M apps/app_voicemail.c<br>M include/asterisk/app.h<br>M include/asterisk/strings.h<br>M main/dns_srv.c<br>M main/http.c<br>M main/logger.c<br>M main/message.c<br>M main/pbx.c<br>M main/pbx_variables.c<br>M main/stasis.c<br>M main/strings.c<br>M pbx/pbx_dundi.c<br>M res/parking/parking_bridge_features.c<br>M res/res_pjsip_registrar.c<br>M tests/test_locale.c<br>20 files changed, 104 insertions(+), 72 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/56/14456/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/Makefile.rules b/Makefile.rules</span><br><span>index 24ecf7f..934e44a 100644</span><br><span>--- a/Makefile.rules</span><br><span>+++ b/Makefile.rules</span><br><span>@@ -63,6 +63,7 @@</span><br><span> endif</span><br><span> </span><br><span> OPTIMIZE?=-O3</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> ifneq ($(findstring darwin,$(OSARCH)),)</span><br><span> ifeq ($(shell if test `/usr/bin/sw_vers -productVersion | cut -c4` -gt 5; then echo 6; else echo 0; fi),6)</span><br><span> # Snow Leopard/Lion has an issue with this optimization flag on large files (like chan_sip)</span><br><span>@@ -70,15 +71,15 @@</span><br><span> endif</span><br><span> endif</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-# gcc version 8.2.1 and above must have partial-inlining disabled to avoid documented bug.</span><br><span style="color: hsl(0, 100%, 40%);">-# We must handle cross-compiling and clang so make sure the compiler version string has "gcc"</span><br><span style="color: hsl(0, 100%, 40%);">-# somewhere in it before testing the version.</span><br><span style="color: hsl(0, 100%, 40%);">-CC_VERS_STRING=$(shell $(CC) --version | grep -i gcc)</span><br><span style="color: hsl(0, 100%, 40%);">-ifneq ($(CC_VERS_STRING),)</span><br><span style="color: hsl(0, 100%, 40%);">-GCC_VER_GTE821:=$(shell expr `echo '$(CC_VERS_STRING)' | cut -d ' ' -f 3 | sed -e 's/\.\([0-9][0-9]\)/\1/g' -e 's/\.\([0-9]\)/0\1/g' -e 's/^[0-9]\{3,4\}$$/&00/'` \>= 80201)</span><br><span style="color: hsl(0, 100%, 40%);">-ifeq ($(GCC_VER_GTE821),1)</span><br><span style="color: hsl(0, 100%, 40%);">- OPTIMIZE+=-fno-partial-inlining</span><br><span style="color: hsl(0, 100%, 40%);">-endif</span><br><span style="color: hsl(120, 100%, 40%);">+ifeq ($(CC),gcc)</span><br><span style="color: hsl(120, 100%, 40%);">+ # gcc version 8.2.1 and above must have partial-inlining disabled in order</span><br><span style="color: hsl(120, 100%, 40%);">+ # to avoid a documented bug. Sort to make the lowest version number come</span><br><span style="color: hsl(120, 100%, 40%);">+ # first. If it's the specified version then the current gcc version is equal</span><br><span style="color: hsl(120, 100%, 40%);">+ # to or greater, so add the custom optimization rule.</span><br><span style="color: hsl(120, 100%, 40%);">+ gcc_versions=$(shell printf "%s\n" $$(gcc -dumpversion) 8.2.1 | sort -n)</span><br><span style="color: hsl(120, 100%, 40%);">+ ifeq ($(firstword $(gcc_versions)),8.2.1)</span><br><span style="color: hsl(120, 100%, 40%);">+ OPTIMIZE+=-fno-partial-inlining</span><br><span style="color: hsl(120, 100%, 40%);">+ endif</span><br><span> endif</span><br><span> </span><br><span> ifeq ($(findstring DONT_OPTIMIZE,$(MENUSELECT_CFLAGS))$(AST_CODE_COVERAGE),no)</span><br><span>diff --git a/addons/ooh323c/src/decode.c b/addons/ooh323c/src/decode.c</span><br><span>index 3ce74bf..d0579c6 100644</span><br><span>--- a/addons/ooh323c/src/decode.c</span><br><span>+++ b/addons/ooh323c/src/decode.c</span><br><span>@@ -737,6 +737,10 @@</span><br><span> nbits -= 8;</span><br><span> }</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+ if (nbits <= 0) {</span><br><span style="color: hsl(120, 100%, 40%);">+ return ASN_OK;</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> /* Copy last partial byte */</span><br><span> </span><br><span> if (nbits >= rshift) {</span><br><span>@@ -752,7 +756,7 @@</span><br><span> </span><br><span> pctxt->buffer.bitOffset = 8 - nbitsInLastOctet;</span><br><span> }</span><br><span style="color: hsl(0, 100%, 40%);">- else if (nbits > 0) { /* nbits < rshift */</span><br><span style="color: hsl(120, 100%, 40%);">+ else { /* nbits > 0 && nbits < rshift */</span><br><span> pbuffer[i] =</span><br><span> pctxt->buffer.data[pctxt->buffer.byteIndex] << lshift;</span><br><span> pctxt->buffer.bitOffset = rshift - nbits;</span><br><span>@@ -832,8 +836,8 @@</span><br><span> </span><br><span> int decodeSemiConsInteger (OOCTXT* pctxt, ASN1INT* pvalue, ASN1INT lower)</span><br><span> {</span><br><span style="color: hsl(0, 100%, 40%);">- signed char b;</span><br><span style="color: hsl(0, 100%, 40%);">- unsigned char ub;</span><br><span style="color: hsl(120, 100%, 40%);">+ signed char b = 0;</span><br><span style="color: hsl(120, 100%, 40%);">+ unsigned char ub = 0;</span><br><span> ASN1UINT nbytes;</span><br><span> int stat;</span><br><span> </span><br><span>diff --git a/addons/ooh323c/src/ooSocket.c b/addons/ooh323c/src/ooSocket.c</span><br><span>index 55bb0ac..151c1cf 100644</span><br><span>--- a/addons/ooh323c/src/ooSocket.c</span><br><span>+++ b/addons/ooh323c/src/ooSocket.c</span><br><span>@@ -389,7 +389,7 @@</span><br><span> </span><br><span> if (destAddr != 0) {</span><br><span> if ((host = ast_sockaddr_stringify_addr(&addr)) != NULL)</span><br><span style="color: hsl(0, 100%, 40%);">- strncpy(destAddr, host, strlen(host));</span><br><span style="color: hsl(120, 100%, 40%);">+ memcpy(destAddr, host, strlen(host) + 1);</span><br><span> }</span><br><span> if (destPort != 0)</span><br><span> *destPort = ast_sockaddr_port(&addr);</span><br><span>diff --git a/addons/ooh323c/src/oochannels.c b/addons/ooh323c/src/oochannels.c</span><br><span>index ca7b09c..3add1f3 100644</span><br><span>--- a/addons/ooh323c/src/oochannels.c</span><br><span>+++ b/addons/ooh323c/src/oochannels.c</span><br><span>@@ -454,7 +454,7 @@</span><br><span> call->callToken);</span><br><span> </span><br><span> if (remoteIP[0]) {</span><br><span style="color: hsl(0, 100%, 40%);">- strncpy(call->remoteIP, remoteIP, strlen(remoteIP));</span><br><span style="color: hsl(120, 100%, 40%);">+ memcpy(call->remoteIP, remoteIP, strlen(remoteIP) + 1);</span><br><span> }</span><br><span> </span><br><span> ast_mutex_unlock(&call->Lock);</span><br><span>diff --git a/apps/app_stack.c b/apps/app_stack.c</span><br><span>index 4560865..179694b 100644</span><br><span>--- a/apps/app_stack.c</span><br><span>+++ b/apps/app_stack.c</span><br><span>@@ -313,13 +313,14 @@</span><br><span> static struct gosub_stack_frame *gosub_allocate_frame(const char *context, const char *extension, int priority, int in_subroutine, unsigned char arguments)</span><br><span> {</span><br><span> struct gosub_stack_frame *new = NULL;</span><br><span style="color: hsl(0, 100%, 40%);">- int len_extension = strlen(extension), len_context = strlen(context);</span><br><span style="color: hsl(120, 100%, 40%);">+ int len_extension = strlen(extension) + 1;</span><br><span style="color: hsl(120, 100%, 40%);">+ int len_context = strlen(context) + 1;</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">- if ((new = ast_calloc(1, sizeof(*new) + 2 + len_extension + len_context))) {</span><br><span style="color: hsl(120, 100%, 40%);">+ if ((new = ast_calloc(1, sizeof(*new) + len_extension + len_context))) {</span><br><span> AST_LIST_HEAD_INIT_NOLOCK(&new->varshead);</span><br><span style="color: hsl(0, 100%, 40%);">- strcpy(new->extension, extension);</span><br><span style="color: hsl(0, 100%, 40%);">- new->context = new->extension + len_extension + 1;</span><br><span style="color: hsl(0, 100%, 40%);">- strcpy(new->context, context);</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_copy_string(new->extension, extension, len_extension);</span><br><span style="color: hsl(120, 100%, 40%);">+ new->context = new->extension + len_extension;</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_copy_string(new->context, context, len_context);</span><br><span> new->priority = priority;</span><br><span> new->in_subroutine = in_subroutine ? 1 : 0;</span><br><span> new->arguments = arguments;</span><br><span>diff --git a/apps/app_voicemail.c b/apps/app_voicemail.c</span><br><span>index 0bd9a6b..ada7382 100644</span><br><span>--- a/apps/app_voicemail.c</span><br><span>+++ b/apps/app_voicemail.c</span><br><span>@@ -1234,10 +1234,12 @@</span><br><span> </span><br><span> static int inprocess_count(const char *context, const char *mailbox, int delta)</span><br><span> {</span><br><span style="color: hsl(0, 100%, 40%);">- struct inprocess *i, *arg = ast_alloca(sizeof(*arg) + strlen(context) + strlen(mailbox) + 2);</span><br><span style="color: hsl(0, 100%, 40%);">- arg->context = arg->mailbox + strlen(mailbox) + 1;</span><br><span style="color: hsl(0, 100%, 40%);">- strcpy(arg->mailbox, mailbox); /* SAFE */</span><br><span style="color: hsl(0, 100%, 40%);">- strcpy(arg->context, context); /* SAFE */</span><br><span style="color: hsl(120, 100%, 40%);">+ int context_len = strlen(context) + 1;</span><br><span style="color: hsl(120, 100%, 40%);">+ int mailbox_len = strlen(mailbox) + 1;</span><br><span style="color: hsl(120, 100%, 40%);">+ struct inprocess *i, *arg = ast_alloca(sizeof(*arg) + context_len + mailbox_len);</span><br><span style="color: hsl(120, 100%, 40%);">+ arg->context = arg->mailbox + mailbox_len;</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_copy_string(arg->mailbox, mailbox, mailbox_len); /* SAFE */</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_copy_string(arg->context, context, context_len); /* SAFE */</span><br><span> ao2_lock(inprocess_container);</span><br><span> if ((i = ao2_find(inprocess_container, arg, 0))) {</span><br><span> int ret = ast_atomic_fetchadd_int(&i->count, delta);</span><br><span>@@ -1248,13 +1250,13 @@</span><br><span> if (delta < 0) {</span><br><span> ast_log(LOG_WARNING, "BUG: ref count decrement on non-existing object???\n");</span><br><span> }</span><br><span style="color: hsl(0, 100%, 40%);">- if (!(i = ao2_alloc(sizeof(*i) + strlen(context) + strlen(mailbox) + 2, NULL))) {</span><br><span style="color: hsl(120, 100%, 40%);">+ if (!(i = ao2_alloc(sizeof(*i) + context_len + mailbox_len, NULL))) {</span><br><span> ao2_unlock(inprocess_container);</span><br><span> return 0;</span><br><span> }</span><br><span style="color: hsl(0, 100%, 40%);">- i->context = i->mailbox + strlen(mailbox) + 1;</span><br><span style="color: hsl(0, 100%, 40%);">- strcpy(i->mailbox, mailbox); /* SAFE */</span><br><span style="color: hsl(0, 100%, 40%);">- strcpy(i->context, context); /* SAFE */</span><br><span style="color: hsl(120, 100%, 40%);">+ i->context = i->mailbox + mailbox_len;</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_copy_string(i->mailbox, mailbox, mailbox_len); /* SAFE */</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_copy_string(i->context, context, context_len); /* SAFE */</span><br><span> i->count = delta;</span><br><span> ao2_link(inprocess_container, i);</span><br><span> ao2_unlock(inprocess_container);</span><br><span>@@ -13350,13 +13352,15 @@</span><br><span> unsigned int len;</span><br><span> struct mwi_sub *mwi_sub;</span><br><span> struct mwi_sub_task *p = datap;</span><br><span style="color: hsl(120, 100%, 40%);">+ size_t context_len;</span><br><span> </span><br><span> len = sizeof(*mwi_sub) + 1;</span><br><span> if (!ast_strlen_zero(p->mailbox))</span><br><span> len += strlen(p->mailbox);</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+ context_len = strlen(p->context) + 1; /* Allow for seperator */</span><br><span> if (!ast_strlen_zero(p->context))</span><br><span style="color: hsl(0, 100%, 40%);">- len += strlen(p->context) + 1; /* Allow for seperator */</span><br><span style="color: hsl(120, 100%, 40%);">+ len += context_len;</span><br><span> </span><br><span> if (!(mwi_sub = ast_calloc(1, len)))</span><br><span> return -1;</span><br><span>@@ -13367,7 +13371,7 @@</span><br><span> </span><br><span> if (!ast_strlen_zero(p->context)) {</span><br><span> strcat(mwi_sub->mailbox, "@");</span><br><span style="color: hsl(0, 100%, 40%);">- strcat(mwi_sub->mailbox, p->context);</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_copy_string(mwi_sub->mailbox, p->context, context_len);</span><br><span> }</span><br><span> </span><br><span> AST_RWLIST_WRLOCK(&mwi_subs);</span><br><span>@@ -13856,8 +13860,8 @@</span><br><span> }</span><br><span> mapping->alias = mapping->buf;</span><br><span> mapping->mailbox = mapping->buf + from_len;</span><br><span style="color: hsl(0, 100%, 40%);">- strcpy(mapping->alias, alias); /* Safe */</span><br><span style="color: hsl(0, 100%, 40%);">- strcpy(mapping->mailbox, mailbox); /* Safe */</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_copy_string(mapping->alias, alias, from_len); /* Safe */</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_copy_string(mapping->mailbox, mailbox, to_len); /* Safe */</span><br><span> </span><br><span> return mapping;</span><br><span> }</span><br><span>diff --git a/include/asterisk/app.h b/include/asterisk/app.h</span><br><span>index 4264556..91d06aa 100644</span><br><span>--- a/include/asterisk/app.h</span><br><span>+++ b/include/asterisk/app.h</span><br><span>@@ -1231,11 +1231,14 @@</span><br><span> \note This defines a structure type, but does not declare an instance</span><br><span> of the structure. That must be done separately.</span><br><span> */</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> #define AST_DEFINE_APP_ARGS_TYPE(type, arglist) \</span><br><span> struct type { \</span><br><span> unsigned int argc; \</span><br><span style="color: hsl(0, 100%, 40%);">- char *argv[0]; \</span><br><span style="color: hsl(0, 100%, 40%);">- arglist \</span><br><span style="color: hsl(120, 100%, 40%);">+ union { \</span><br><span style="color: hsl(120, 100%, 40%);">+ char *argv[sizeof(struct {arglist}) / sizeof(char *)]; \</span><br><span style="color: hsl(120, 100%, 40%);">+ struct {arglist}; \</span><br><span style="color: hsl(120, 100%, 40%);">+ }; \</span><br><span> }</span><br><span> </span><br><span> /*!</span><br><span>diff --git a/include/asterisk/strings.h b/include/asterisk/strings.h</span><br><span>index c56a139..20d2505 100644</span><br><span>--- a/include/asterisk/strings.h</span><br><span>+++ b/include/asterisk/strings.h</span><br><span>@@ -1221,6 +1221,7 @@</span><br><span> </span><br><span> for (; *str; ++str) {</span><br><span> *str = tolower(*str);</span><br><span style="color: hsl(120, 100%, 40%);">+ /* ast_log(LOG_VERBOSE, "#### return it = %c\n", *str); /\* 449dff997c29a247fe36000420fb0fcaf5542867 *\/ */</span><br><span> }</span><br><span> </span><br><span> return str_orig;</span><br><span>diff --git a/main/dns_srv.c b/main/dns_srv.c</span><br><span>index e11c84e..4847f89 100644</span><br><span>--- a/main/dns_srv.c</span><br><span>+++ b/main/dns_srv.c</span><br><span>@@ -49,6 +49,7 @@</span><br><span> struct ast_dns_srv_record *srv;</span><br><span> int host_size;</span><br><span> char host[NI_MAXHOST] = "";</span><br><span style="color: hsl(120, 100%, 40%);">+ size_t host_len;</span><br><span> </span><br><span> ptr = dns_find_record(data, size, query->result->answer, query->result->answer_size);</span><br><span> ast_assert(ptr != NULL);</span><br><span>@@ -89,7 +90,8 @@</span><br><span> return NULL;</span><br><span> }</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">- srv = ast_calloc(1, sizeof(*srv) + size + strlen(host) + 1);</span><br><span style="color: hsl(120, 100%, 40%);">+ host_len = strlen(host) + 1;</span><br><span style="color: hsl(120, 100%, 40%);">+ srv = ast_calloc(1, sizeof(*srv) + size + host_len);</span><br><span> if (!srv) {</span><br><span> return NULL;</span><br><span> }</span><br><span>@@ -99,7 +101,7 @@</span><br><span> srv->port = port;</span><br><span> </span><br><span> srv->host = srv->data + size;</span><br><span style="color: hsl(0, 100%, 40%);">- strcpy((char *)srv->host, host); /* SAFE */</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_copy_string((char *)srv->host, host, host_len); /* SAFE */</span><br><span> srv->generic.data_ptr = srv->data;</span><br><span> </span><br><span> return (struct ast_dns_record *)srv;</span><br><span>diff --git a/main/http.c b/main/http.c</span><br><span>index 3088552..a0f15f4 100644</span><br><span>--- a/main/http.c</span><br><span>+++ b/main/http.c</span><br><span>@@ -2025,6 +2025,7 @@</span><br><span> struct http_uri_redirect *redirect, *cur;</span><br><span> unsigned int target_len;</span><br><span> unsigned int total_len;</span><br><span style="color: hsl(120, 100%, 40%);">+ size_t dest_len;</span><br><span> </span><br><span> dest = ast_strdupa(value);</span><br><span> dest = ast_skip_blanks(dest);</span><br><span>@@ -2038,14 +2039,15 @@</span><br><span> }</span><br><span> </span><br><span> target_len = strlen(target) + 1;</span><br><span style="color: hsl(0, 100%, 40%);">- total_len = sizeof(*redirect) + target_len + strlen(dest) + 1;</span><br><span style="color: hsl(120, 100%, 40%);">+ dest_len = strlen(dest) + 1;</span><br><span style="color: hsl(120, 100%, 40%);">+ total_len = sizeof(*redirect) + target_len + dest_len;</span><br><span> </span><br><span> if (!(redirect = ast_calloc(1, total_len))) {</span><br><span> return;</span><br><span> }</span><br><span> redirect->dest = redirect->target + target_len;</span><br><span> strcpy(redirect->target, target);</span><br><span style="color: hsl(0, 100%, 40%);">- strcpy(redirect->dest, dest);</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_copy_string(redirect->dest, dest, dest_len);</span><br><span> </span><br><span> AST_RWLIST_WRLOCK(&uri_redirects);</span><br><span> </span><br><span>diff --git a/main/logger.c b/main/logger.c</span><br><span>index cf9357e..c66d820 100644</span><br><span>--- a/main/logger.c</span><br><span>+++ b/main/logger.c</span><br><span>@@ -2294,7 +2294,7 @@</span><br><span> va_list ap;</span><br><span> unsigned long indent = (unsigned long)ast_threadstorage_get_ptr(&trace_indent);</span><br><span> struct ast_str *fmt = ast_str_create(128);</span><br><span style="color: hsl(0, 100%, 40%);">- char *direction;</span><br><span style="color: hsl(120, 100%, 40%);">+ const char *direction = "";</span><br><span> </span><br><span> if (!fmt) {</span><br><span> return;</span><br><span>diff --git a/main/message.c b/main/message.c</span><br><span>index dc81b4e..66d051c 100644</span><br><span>--- a/main/message.c</span><br><span>+++ b/main/message.c</span><br><span>@@ -1421,7 +1421,7 @@</span><br><span> /* Set the ones we have and increment the offset */</span><br><span> for (i=0; i < count; i++) {</span><br><span> len = (strlen(attributes[i].value) + 1);</span><br><span style="color: hsl(0, 100%, 40%);">- strcpy(msg->buf + current_offset, attributes[i].value); /* Safe */</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_copy_string(msg->buf + current_offset, attributes[i].value, len); /* Safe */</span><br><span> msg->attribute_value_offsets[attributes[i].type] = current_offset;</span><br><span> current_offset += len;</span><br><span> }</span><br><span>diff --git a/main/pbx.c b/main/pbx.c</span><br><span>index f7b813b..bbc6df9 100644</span><br><span>--- a/main/pbx.c</span><br><span>+++ b/main/pbx.c</span><br><span>@@ -6519,6 +6519,8 @@</span><br><span> i = ao2_iterator_init(hints, AO2_ITERATOR_DONTLOCK);</span><br><span> for (; (hint = ao2_iterator_next(&i)); ao2_ref(hint, -1)) {</span><br><span> if (ao2_container_count(hint->callbacks)) {</span><br><span style="color: hsl(120, 100%, 40%);">+ size_t exten_len;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> ao2_lock(hint);</span><br><span> if (!hint->exten) {</span><br><span> /* The extension has already been destroyed. (Should never happen here) */</span><br><span>@@ -6526,7 +6528,8 @@</span><br><span> continue;</span><br><span> }</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">- length = strlen(hint->exten->exten) + strlen(hint->exten->parent->name) + 2</span><br><span style="color: hsl(120, 100%, 40%);">+ exten_len = strlen(hint->exten->exten) + 1;</span><br><span style="color: hsl(120, 100%, 40%);">+ length = exten_len + strlen(hint->exten->parent->name) + 1</span><br><span> + sizeof(*saved_hint);</span><br><span> if (!(saved_hint = ast_calloc(1, length))) {</span><br><span> ao2_unlock(hint);</span><br><span>@@ -6546,7 +6549,7 @@</span><br><span> saved_hint->context = saved_hint->data;</span><br><span> strcpy(saved_hint->data, hint->exten->parent->name);</span><br><span> saved_hint->exten = saved_hint->data + strlen(saved_hint->context) + 1;</span><br><span style="color: hsl(0, 100%, 40%);">- strcpy(saved_hint->exten, hint->exten->exten);</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_copy_string(saved_hint->exten, hint->exten->exten, exten_len);</span><br><span> if (hint->last_presence_subtype) {</span><br><span> saved_hint->last_presence_subtype = ast_strdup(hint->last_presence_subtype);</span><br><span> }</span><br><span>diff --git a/main/pbx_variables.c b/main/pbx_variables.c</span><br><span>index c1463d0..e3c26f8 100644</span><br><span>--- a/main/pbx_variables.c</span><br><span>+++ b/main/pbx_variables.c</span><br><span>@@ -211,14 +211,10 @@</span><br><span> }</span><br><span> </span><br><span> if (length >= 0 && length < lr) { /* truncate if necessary */</span><br><span style="color: hsl(0, 100%, 40%);">- char *tmp = ast_str_buffer(value);</span><br><span style="color: hsl(0, 100%, 40%);">- tmp[length] = '\0';</span><br><span style="color: hsl(0, 100%, 40%);">- ast_str_update(value);</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_str_truncate(value, length);</span><br><span> } else if (length < 0) {</span><br><span> if (lr > -length) { /* After we remove from the front and from the rear, is there anything left? */</span><br><span style="color: hsl(0, 100%, 40%);">- char *tmp = ast_str_buffer(value);</span><br><span style="color: hsl(0, 100%, 40%);">- tmp[lr + length] = '\0';</span><br><span style="color: hsl(0, 100%, 40%);">- ast_str_update(value);</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_str_truncate(value, lr + length);</span><br><span> } else {</span><br><span> ast_str_reset(value);</span><br><span> }</span><br><span>diff --git a/main/stasis.c b/main/stasis.c</span><br><span>index 9799ee6..ab6f42c 100644</span><br><span>--- a/main/stasis.c</span><br><span>+++ b/main/stasis.c</span><br><span>@@ -498,6 +498,7 @@</span><br><span> {</span><br><span> struct topic_proxy *proxy;</span><br><span> struct stasis_topic* topic_tmp;</span><br><span style="color: hsl(120, 100%, 40%);">+ size_t detail_len;</span><br><span> </span><br><span> if (!topic || !name || !strlen(name) || !detail) {</span><br><span> return -1;</span><br><span>@@ -514,8 +515,10 @@</span><br><span> return -1;</span><br><span> }</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+ detail_len = strlen(detail) + 1;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> proxy = ao2_t_weakproxy_alloc(</span><br><span style="color: hsl(0, 100%, 40%);">- sizeof(*proxy) + strlen(name) + 1 + strlen(detail) + 1, NULL, name);</span><br><span style="color: hsl(120, 100%, 40%);">+ sizeof(*proxy) + strlen(name) + 1 + detail_len, NULL, name);</span><br><span> if (!proxy) {</span><br><span> ao2_unlock(topic_all);</span><br><span> </span><br><span>@@ -527,7 +530,7 @@</span><br><span> proxy->detail = proxy->name + strlen(name) + 1;</span><br><span> </span><br><span> strcpy(proxy->name, name); /* SAFE */</span><br><span style="color: hsl(0, 100%, 40%);">- strcpy(proxy->detail, detail); /* SAFE */</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_copy_string(proxy->detail, detail, detail_len); /* SAFE */</span><br><span> proxy->creationtime = ast_tvnow();</span><br><span> </span><br><span> /* We have exclusive access to proxy, no need for locking here. */</span><br><span>@@ -1620,9 +1623,10 @@</span><br><span> static struct stasis_subscription_change *subscription_change_alloc(struct stasis_topic *topic, const char *uniqueid, const char *description)</span><br><span> {</span><br><span> size_t description_len = strlen(description) + 1;</span><br><span style="color: hsl(120, 100%, 40%);">+ size_t uniqueid_len = strlen(uniqueid) + 1;</span><br><span> struct stasis_subscription_change *change;</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">- change = ao2_alloc_options(sizeof(*change) + description_len + strlen(uniqueid) + 1,</span><br><span style="color: hsl(120, 100%, 40%);">+ change = ao2_alloc_options(sizeof(*change) + description_len + uniqueid_len,</span><br><span> subscription_change_dtor, AO2_ALLOC_OPT_LOCK_NOLOCK);</span><br><span> if (!change) {</span><br><span> return NULL;</span><br><span>@@ -1630,7 +1634,7 @@</span><br><span> </span><br><span> strcpy(change->description, description); /* SAFE */</span><br><span> change->uniqueid = change->description + description_len;</span><br><span style="color: hsl(0, 100%, 40%);">- strcpy(change->uniqueid, uniqueid); /* SAFE */</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_copy_string(change->uniqueid, uniqueid, uniqueid_len); /* SAFE */</span><br><span> ao2_ref(topic, +1);</span><br><span> change->topic = topic;</span><br><span> </span><br><span>diff --git a/main/strings.c b/main/strings.c</span><br><span>index 0cd4692..f41a81d 100644</span><br><span>--- a/main/strings.c</span><br><span>+++ b/main/strings.c</span><br><span>@@ -42,6 +42,8 @@</span><br><span> #include "asterisk/pbx.h"</span><br><span> #include "asterisk/vector.h"</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> /*!</span><br><span> * core handler for dynamic strings.</span><br><span> * This is not meant to be called directly, but rather through the</span><br><span>diff --git a/pbx/pbx_dundi.c b/pbx/pbx_dundi.c</span><br><span>index 1ab0676..a504171 100644</span><br><span>--- a/pbx/pbx_dundi.c</span><br><span>+++ b/pbx/pbx_dundi.c</span><br><span>@@ -722,7 +722,7 @@</span><br><span> {</span><br><span> struct dundi_query_state *st = data;</span><br><span> struct dundi_ie_data ied;</span><br><span style="color: hsl(0, 100%, 40%);">- struct dundi_hint_metadata hmd;</span><br><span style="color: hsl(120, 100%, 40%);">+ struct dundi_hint_metadata hmd = {0};</span><br><span> char eid_str[20];</span><br><span> </span><br><span> ast_debug(1, "Whee, precaching '%s@%s' for '%s'\n", st->called_number, st->called_context,</span><br><span>@@ -3936,7 +3936,6 @@</span><br><span> </span><br><span> static void reschedule_precache(const char *number, const char *context, int expiration)</span><br><span> {</span><br><span style="color: hsl(0, 100%, 40%);">- int len;</span><br><span> struct dundi_precache_queue *qe, *prev;</span><br><span> </span><br><span> AST_LIST_LOCK(&pcq);</span><br><span>@@ -3948,16 +3947,16 @@</span><br><span> }</span><br><span> AST_LIST_TRAVERSE_SAFE_END;</span><br><span> if (!qe) {</span><br><span style="color: hsl(0, 100%, 40%);">- len = sizeof(*qe);</span><br><span style="color: hsl(0, 100%, 40%);">- len += strlen(number) + 1;</span><br><span style="color: hsl(0, 100%, 40%);">- len += strlen(context) + 1;</span><br><span style="color: hsl(0, 100%, 40%);">- if (!(qe = ast_calloc(1, len))) {</span><br><span style="color: hsl(120, 100%, 40%);">+ int len = sizeof(*qe);</span><br><span style="color: hsl(120, 100%, 40%);">+ int num_len = strlen(number) + 1;</span><br><span style="color: hsl(120, 100%, 40%);">+ int context_len = strlen(context) + 1;</span><br><span style="color: hsl(120, 100%, 40%);">+ if (!(qe = ast_calloc(1, len + num_len + context_len))) {</span><br><span> AST_LIST_UNLOCK(&pcq);</span><br><span> return;</span><br><span> }</span><br><span> strcpy(qe->number, number);</span><br><span style="color: hsl(0, 100%, 40%);">- qe->context = qe->number + strlen(number) + 1;</span><br><span style="color: hsl(0, 100%, 40%);">- strcpy(qe->context, context);</span><br><span style="color: hsl(120, 100%, 40%);">+ qe->context = qe->number + num_len + 1;</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_copy_string(qe->context, context, context_len);</span><br><span> }</span><br><span> time(&qe->expiration);</span><br><span> qe->expiration += expiration;</span><br><span>diff --git a/res/parking/parking_bridge_features.c b/res/parking/parking_bridge_features.c</span><br><span>index 1278894..8c547aa 100644</span><br><span>--- a/res/parking/parking_bridge_features.c</span><br><span>+++ b/res/parking/parking_bridge_features.c</span><br><span>@@ -179,7 +179,8 @@</span><br><span> struct parked_subscription_data *subscription_data;</span><br><span> </span><br><span> char *parker_uuid = ast_strdupa(ast_channel_uniqueid(chan));</span><br><span style="color: hsl(0, 100%, 40%);">- size_t parker_uuid_size = strlen(parker_uuid) + 1;</span><br><span style="color: hsl(120, 100%, 40%);">+ size_t parker_uuid_size;</span><br><span style="color: hsl(120, 100%, 40%);">+ size_t parkee_uuid_size;</span><br><span> </span><br><span> /* If there is already a subscription, get rid of it. */</span><br><span> wipe_subscription_datastore(chan);</span><br><span>@@ -193,8 +194,11 @@</span><br><span> return -1;</span><br><span> }</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+ parker_uuid_size = strlen(parker_uuid) + 1;</span><br><span style="color: hsl(120, 100%, 40%);">+ parkee_uuid_size = strlen(parkee_uuid) + 1;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> if (!(subscription_data = ast_calloc(1, sizeof(*subscription_data) + parker_uuid_size +</span><br><span style="color: hsl(0, 100%, 40%);">- strlen(parkee_uuid) + 1))) {</span><br><span style="color: hsl(120, 100%, 40%);">+ parkee_uuid_size))) {</span><br><span> ast_datastore_free(datastore);</span><br><span> ast_free(parked_datastore);</span><br><span> return -1;</span><br><span>@@ -207,8 +211,7 @@</span><br><span> </span><br><span> subscription_data->hangup_after = hangup_after;</span><br><span> subscription_data->parkee_uuid = subscription_data->parker_uuid + parker_uuid_size;</span><br><span style="color: hsl(0, 100%, 40%);">- strcpy(subscription_data->parkee_uuid, parkee_uuid);</span><br><span style="color: hsl(0, 100%, 40%);">- strcpy(subscription_data->parker_uuid, parker_uuid);</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_copy_string(subscription_data->parkee_uuid, parkee_uuid, parkee_uuid_size);</span><br><span> </span><br><span> if (!(parked_datastore->parked_subscription = stasis_subscribe_pool(ast_parking_topic(), parker_update_cb, subscription_data))) {</span><br><span> return -1;</span><br><span>diff --git a/res/res_pjsip_registrar.c b/res/res_pjsip_registrar.c</span><br><span>index 172ecc8..523eb0a 100644</span><br><span>--- a/res/res_pjsip_registrar.c</span><br><span>+++ b/res/res_pjsip_registrar.c</span><br><span>@@ -422,12 +422,13 @@</span><br><span> aor_size = aor_name ? strlen(aor_name) : 0;</span><br><span> if (contact->prune_on_boot && type != CONTACT_DELETE_SHUTDOWN && aor_size) {</span><br><span> const char *contact_name = ast_sorcery_object_get_id(contact);</span><br><span style="color: hsl(120, 100%, 40%);">+ size_t contact_name_len = strlen(contact_name) + 1;</span><br><span> struct contact_transport_monitor *monitor = ast_alloca(</span><br><span style="color: hsl(0, 100%, 40%);">- sizeof(*monitor) + 2 + aor_size + strlen(contact_name));</span><br><span style="color: hsl(120, 100%, 40%);">+ sizeof(*monitor) + 1 + aor_size + contact_name_len);</span><br><span> </span><br><span> strcpy(monitor->aor_name, aor_name); /* Safe */</span><br><span> monitor->contact_name = monitor->aor_name + aor_size + 1;</span><br><span style="color: hsl(0, 100%, 40%);">- strcpy(monitor->contact_name, contact_name); /* Safe */</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_copy_string(monitor->contact_name, contact_name, contact_name_len); /* Safe */</span><br><span> </span><br><span> if (transport) {</span><br><span> ast_sip_transport_monitor_unregister(transport,</span><br><span>@@ -774,6 +775,7 @@</span><br><span> }</span><br><span> </span><br><span> if (prune_on_boot) {</span><br><span style="color: hsl(120, 100%, 40%);">+ size_t contact_name_len;</span><br><span> const char *contact_name;</span><br><span> struct contact_transport_monitor *monitor;</span><br><span> </span><br><span>@@ -782,12 +784,13 @@</span><br><span> * the contact won't be valid anymore if that happens.</span><br><span> */</span><br><span> contact_name = ast_sorcery_object_get_id(contact);</span><br><span style="color: hsl(0, 100%, 40%);">- monitor = ao2_alloc(sizeof(*monitor) + 2 + strlen(aor_name)</span><br><span style="color: hsl(0, 100%, 40%);">- + strlen(contact_name), NULL);</span><br><span style="color: hsl(120, 100%, 40%);">+ contact_name_len = strlen(contact_name) + 1;</span><br><span style="color: hsl(120, 100%, 40%);">+ monitor = ao2_alloc(sizeof(*monitor) + 1 + strlen(aor_name)</span><br><span style="color: hsl(120, 100%, 40%);">+ + contact_name_len, NULL);</span><br><span> if (monitor) {</span><br><span> strcpy(monitor->aor_name, aor_name);/* Safe */</span><br><span> monitor->contact_name = monitor->aor_name + strlen(aor_name) + 1;</span><br><span style="color: hsl(0, 100%, 40%);">- strcpy(monitor->contact_name, contact_name);/* Safe */</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_copy_string(monitor->contact_name, contact_name, contact_name_len);/* Safe */</span><br><span> </span><br><span> ast_sip_transport_monitor_register_replace(rdata->tp_info.transport,</span><br><span> register_contact_transport_shutdown_cb, monitor, contact_transport_monitor_matcher);</span><br><span>diff --git a/tests/test_locale.c b/tests/test_locale.c</span><br><span>index 99137c1..4fd6a34 100644</span><br><span>--- a/tests/test_locale.c</span><br><span>+++ b/tests/test_locale.c</span><br><span>@@ -98,6 +98,7 @@</span><br><span> ast_strftime(origlocalformat, sizeof(origlocalformat), "%c", &atm);</span><br><span> </span><br><span> while ((dent = readdir(localedir))) {</span><br><span style="color: hsl(120, 100%, 40%);">+ size_t locallen;</span><br><span> size_t namelen;</span><br><span> </span><br><span> if (dent->d_name[0] == '.') {</span><br><span>@@ -107,14 +108,17 @@</span><br><span> setlocale(LC_ALL, dent->d_name);</span><br><span> ast_strftime(localformat, sizeof(localformat), "%c", &atm);</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+ locallen = strlen(localformat) + 1;</span><br><span style="color: hsl(120, 100%, 40%);">+ namelen = strlen(dent->d_name) + 1;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> /* Store values */</span><br><span style="color: hsl(0, 100%, 40%);">- if (!(tl = ast_calloc(1, sizeof(*tl) + strlen(localformat) + (namelen = strlen(dent->d_name)) + 2))) {</span><br><span style="color: hsl(120, 100%, 40%);">+ if (!(tl = ast_calloc(1, sizeof(*tl) + locallen + namelen))) {</span><br><span> continue;</span><br><span> }</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">- strcpy(tl->name, dent->d_name); /* SAFE */</span><br><span style="color: hsl(0, 100%, 40%);">- tl->localformat = tl->name + namelen + 1;</span><br><span style="color: hsl(0, 100%, 40%);">- strcpy(tl->localformat, localformat); /* SAFE */</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_copy_string(tl->name, dent->d_name, namelen); /* SAFE */</span><br><span style="color: hsl(120, 100%, 40%);">+ tl->localformat = tl->name + namelen;</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_copy_string(tl->localformat, localformat, locallen); /* SAFE */</span><br><span> </span><br><span> AST_LIST_INSERT_TAIL(&locales, tl, list);</span><br><span> </span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/c/asterisk/+/14456">change 14456</a>. To unsubscribe, or for help writing mail filters, 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/c/asterisk/+/14456"/><meta itemprop="name" content="View Change"/></div></div>
<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: 16 </div>
<div style="display:none"> Gerrit-Change-Id: I54718496eb0c3ce5bd6d427cd279a29e8d2825f9 </div>
<div style="display:none"> Gerrit-Change-Number: 14456 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Kevin Harwell <kharwell@digium.com> </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>