[Asterisk-code-review] chan_dahdi: Address gcc9 issues (...asterisk[13])
George Joseph
asteriskteam at digium.com
Fri Jun 21 09:44:47 CDT 2019
George Joseph has submitted this change and it was merged. ( https://gerrit.asterisk.org/c/asterisk/+/11474 )
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; Approved for Submit
diff --git a/channels/chan_dahdi.c b/channels/chan_dahdi.c
index d425b32..8b70447 100644
--- a/channels/chan_dahdi.c
+++ b/channels/chan_dahdi.c
@@ -7740,8 +7740,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 ea0c31d..c2e3e49 100644
--- a/channels/sig_analog.c
+++ b/channels/sig_analog.c
@@ -2957,11 +2957,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/+/11474
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings
Gerrit-Project: asterisk
Gerrit-Branch: 13
Gerrit-Change-Id: Idc1f3c1565b88a7d145332a0196074b5832864e5
Gerrit-Change-Number: 11474
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/d3482d65/attachment.html>
More information about the asterisk-code-review
mailing list