[Asterisk-code-review] chan_dahdi: Address gcc9 issues (...asterisk[16])
Friendly Automation
asteriskteam at digium.com
Fri Jun 21 09:26:05 CDT 2019
Friendly Automation has submitted this change and it was merged. ( https://gerrit.asterisk.org/c/asterisk/+/11475 )
Change subject: chan_dahdi: Address gcc9 issues
......................................................................
chan_dahdi: Address gcc9 issues
Fixed format-truncation issues in chan_dahdi.c and
sig_analog.c. Since they're related to fields provided
by dahdi-tools we can't change the buffer sizes so we're just
checking the return from snprintf and printing an errior if we
overflow.
Change-Id: Idc1f3c1565b88a7d145332a0196074b5832864e5
---
M channels/chan_dahdi.c
M channels/sig_analog.c
2 files changed, 16 insertions(+), 3 deletions(-)
Approvals:
Kevin Harwell: Looks good to me, but someone else must approve
Joshua Colp: Looks good to me, but someone else must approve
George Joseph: Looks good to me, approved
Friendly Automation: Approved for Submit
diff --git a/channels/chan_dahdi.c b/channels/chan_dahdi.c
index 29d3b91..f428530 100644
--- a/channels/chan_dahdi.c
+++ b/channels/chan_dahdi.c
@@ -7673,8 +7673,16 @@
c++;
else
c = p->dialdest;
- if (*c) snprintf(p->dop.dialstr, sizeof(p->dop.dialstr), "M*0%s#", c);
- else ast_copy_string(p->dop.dialstr,"M*2#", sizeof(p->dop.dialstr));
+
+ if (*c) {
+ int numchars = snprintf(p->dop.dialstr, sizeof(p->dop.dialstr), "M*0%s#", c);
+ if (numchars >= sizeof(p->dop.dialstr)) {
+ ast_log(LOG_WARNING, "Dial string '%s' truncated\n", c);
+ }
+ } else {
+ ast_copy_string(p->dop.dialstr,"M*2#", sizeof(p->dop.dialstr));
+ }
+
if (strlen(p->dop.dialstr) > 4) {
memset(p->echorest, 'w', sizeof(p->echorest) - 1);
strcpy(p->echorest + (p->echotraining / 401) + 1, p->dop.dialstr + strlen(p->dop.dialstr) - 2);
diff --git a/channels/sig_analog.c b/channels/sig_analog.c
index 74b4789..4356e02 100644
--- a/channels/sig_analog.c
+++ b/channels/sig_analog.c
@@ -2968,11 +2968,16 @@
} else {
c = p->dialdest;
}
+
if (*c) {
- snprintf(p->dop.dialstr, sizeof(p->dop.dialstr), "M*0%s#", c);
+ int numchars = snprintf(p->dop.dialstr, sizeof(p->dop.dialstr), "M*0%s#", c);
+ if (numchars >= sizeof(p->dop.dialstr)) {
+ ast_log(LOG_WARNING, "Dial string '%s' truncated\n", c);
+ }
} else {
ast_copy_string(p->dop.dialstr,"M*2#", sizeof(p->dop.dialstr));
}
+
if (strlen(p->dop.dialstr) > 4) {
memset(p->echorest, 'w', sizeof(p->echorest) - 1);
strcpy(p->echorest + (p->echotraining / 401) + 1, p->dop.dialstr + strlen(p->dop.dialstr) - 2);
--
To view, visit https://gerrit.asterisk.org/c/asterisk/+/11475
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings
Gerrit-Project: asterisk
Gerrit-Branch: 16
Gerrit-Change-Id: Idc1f3c1565b88a7d145332a0196074b5832864e5
Gerrit-Change-Number: 11475
Gerrit-PatchSet: 2
Gerrit-Owner: George Joseph <gjoseph at digium.com>
Gerrit-Reviewer: Friendly Automation
Gerrit-Reviewer: George Joseph <gjoseph at digium.com>
Gerrit-Reviewer: Joshua Colp <jcolp at digium.com>
Gerrit-Reviewer: Kevin Harwell <kharwell at digium.com>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20190621/65024b71/attachment.html>
More information about the asterisk-code-review
mailing list