[asterisk-bugs] [JIRA] (ASTERISK-24500) Regression introduced in chan_mgcp by SVN revision r227276
Xavier Hienne (JIRA)
noreply at issues.asterisk.org
Fri Nov 7 10:30:29 CST 2014
[ https://issues.asterisk.org/jira/browse/ASTERISK-24500?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=223403#comment-223403 ]
Xavier Hienne commented on ASTERISK-24500:
------------------------------------------
OK, DLA now signed. I have attached a patch against the Asterisk-11 branch. It should apply nicely to the 1.8, 12 and 13 branches (with some line offset though). Tested with Asterisk 11.
This patch removes the remaining "g = g->next" inside the for() loop, as they are redundant with what is done in the for() statement. In the best case scenario, this bug would skip the next gateway in the list; in the worst case, it would trigger a segfault as g migh be NULL when "g->next" is evaluated in the for() statement.
> Regression introduced in chan_mgcp by SVN revision r227276
> ----------------------------------------------------------
>
> Key: ASTERISK-24500
> URL: https://issues.asterisk.org/jira/browse/ASTERISK-24500
> Project: Asterisk
> Issue Type: Bug
> Security Level: None
> Components: Channels/chan_mgcp
> Affects Versions: SVN, 1.8.32.0, 11.14.0, 12.6.1, 13.0.0
> Reporter: Xavier Hienne
> Assignee: Xavier Hienne
> Attachments: chan_mgcp.patch
>
>
> In SVN revision r227276, a while() loop was turned into a for() loop.
> {code}
> @@ -1804,14 +1737,12 @@
> if (at && (at[0] == '[')) {
> at++;
> c = strrchr(at, ']');
> - if (c)
> + if (c) {
> *c = '\0';
> + }
> }
> - g = gateways;
> - if(!g)
> - g = find_realtime_gw(name, at, sin);
> - while(g) {
> - if ((!name || !strcasecmp(g->name, at)) &&
> + for (g = gateways ? gateways : find_realtime_gw(name, at, sin); g; g = g->next ? g->next : find_realtime_gw(name, at, sin)) {
> + if ((!name || !strcasecmp(g->name, at)) &&
> {code}
> Following this, parts of the code like the chunk below were removed since it's now done in the for() line:
> {code}
> @@ -1841,48 +1770,21 @@
> continue;
> }
> } else {
> - if(!g->next)
> - g = find_realtime_gw(name, at, sin);
> - else
> - g = g->next;
> continue;
> }
> {code}
> The problem is that one such code chunk was forgotten and is still here in the "else if (!name && sin)" block, duplicating what is already done in the for() line.
> The end result is that instead of going through the linked list of MGCP gateways one by one, when a static unnamed MGCP GW is encountered in the list, the next GW is skipped.
--
This message was sent by Atlassian JIRA
(v6.2#6252)
More information about the asterisk-bugs
mailing list