]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
pbx_dundi: Fix debug frame decode string.
authorRichard Mudgett <rmudgett@digium.com>
Wed, 15 Aug 2018 23:14:52 +0000 (18:14 -0500)
committerRichard Mudgett <rmudgett@digium.com>
Fri, 17 Aug 2018 19:41:04 +0000 (14:41 -0500)
* 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

pbx/dundi-parser.c

index daa7d718eb0325982479f8328e683d9902ab2bae..15793e28e169e4e7d896b6021c30234b5d1023dd 100644 (file)
@@ -448,7 +448,7 @@ void dundi_showframe(struct dundi_hdr *fhi, int rx, struct sockaddr_in *sin, int
                "INVALID     ",
                "UNKNOWN CMD ",
                "NULL        ",
-               "REQREQ      ",
+               "REGREQ      ",
                "REGRESPONSE ",
                "CANCEL      ",
                "ENCRYPT     ",
@@ -458,15 +458,15 @@ void dundi_showframe(struct dundi_hdr *fhi, int rx, struct sockaddr_in *sin, int
        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");