[Asterisk-code-review] chan_dahdi: Address gcc9 issues (...asterisk[master])

George Joseph asteriskteam at digium.com
Fri Jun 21 09:44:56 CDT 2019


George Joseph has submitted this change and it was merged. ( https://gerrit.asterisk.org/c/asterisk/+/11476 )

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 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/+/11476
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings

Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-Change-Id: Idc1f3c1565b88a7d145332a0196074b5832864e5
Gerrit-Change-Number: 11476
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/5348a56d/attachment-0001.html>


More information about the asterisk-code-review mailing list