[Asterisk-code-review] pbx dundi: Fix debug frame decode string. (asterisk[13])

Joshua Colp asteriskteam at digium.com
Tue Aug 21 05:52:26 CDT 2018


Joshua Colp has submitted this change and it was merged. ( https://gerrit.asterisk.org/9944 )

Change subject: pbx_dundi: Fix debug frame decode string.
......................................................................

pbx_dundi: Fix debug frame decode string.

* Fixed a typo in the name of the REGREQ frame decode string array.
* Fixed off by one range check indexing into the frame decode string
array.
* Removed some unneeded casts associated with the decode string array.

Change-Id: I77435e81cd284bab6209d545919bf236ad7933c2
---
M pbx/dundi-parser.c
1 file changed, 6 insertions(+), 6 deletions(-)

Approvals:
  George Joseph: Looks good to me, but someone else must approve
  Benjamin Keith Ford: Looks good to me, but someone else must approve
  Joshua Colp: Looks good to me, approved; Approved for Submit



diff --git a/pbx/dundi-parser.c b/pbx/dundi-parser.c
index daa7d71..15793e2 100644
--- a/pbx/dundi-parser.c
+++ b/pbx/dundi-parser.c
@@ -448,7 +448,7 @@
 		"INVALID     ",
 		"UNKNOWN CMD ",
 		"NULL        ",
-		"REQREQ      ",
+		"REGREQ      ",
 		"REGRESPONSE ",
 		"CANCEL      ",
 		"ENCRYPT     ",
@@ -458,15 +458,15 @@
 	char subclass2[20];
 	char *subclass;
 	char tmp[256];
-	if ((fhi->cmdresp & 0x3f) > (int)sizeof(commands)/(int)sizeof(char *)) {
-		snprintf(class2, (int)sizeof(class2), "(%d?)", fhi->cmdresp);
+	if ((fhi->cmdresp & 0x3f) >= ARRAY_LEN(commands)) {
+		snprintf(class2, sizeof(class2), "(%d?)", fhi->cmdresp & 0x3f);
 		class = class2;
 	} else {
-		class = commands[(int)(fhi->cmdresp & 0x3f)];
+		class = commands[fhi->cmdresp & 0x3f];
 	}
-	snprintf(subclass2, (int)sizeof(subclass2), "%02hhx", (unsigned char)fhi->cmdflags);
+	snprintf(subclass2, sizeof(subclass2), "%02hhx", (unsigned char)fhi->cmdflags);
 	subclass = subclass2;
-	snprintf(tmp, (int)sizeof(tmp),
+	snprintf(tmp, sizeof(tmp),
 		"%s-Frame -- OSeqno: %3.3d ISeqno: %3.3d Type: %s (%s)\n",
 		pref[rx],
 		fhi->oseqno, fhi->iseqno, class, fhi->cmdresp & 0x40 ? "Response" : "Command");

-- 
To view, visit https://gerrit.asterisk.org/9944
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings

Gerrit-Project: asterisk
Gerrit-Branch: 13
Gerrit-MessageType: merged
Gerrit-Change-Id: I77435e81cd284bab6209d545919bf236ad7933c2
Gerrit-Change-Number: 9944
Gerrit-PatchSet: 1
Gerrit-Owner: Richard Mudgett <rmudgett at digium.com>
Gerrit-Reviewer: Benjamin Keith Ford <bford at digium.com>
Gerrit-Reviewer: George Joseph <gjoseph at digium.com>
Gerrit-Reviewer: Jenkins2
Gerrit-Reviewer: Joshua Colp <jcolp at digium.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20180821/6e871d33/attachment.html>


More information about the asterisk-code-review mailing list