[asterisk-bugs] [JIRA] Updated: (ASTERISK-17797) Coding error in find_subchannel_and_lock()
Richard Mudgett (JIRA)
noreply at issues.asterisk.org
Tue Aug 7 11:41:07 CDT 2012
[ https://issues.asterisk.org/jira/browse/ASTERISK-17797?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Richard Mudgett updated ASTERISK-17797:
---------------------------------------
Description:
The function find_subchannel_and_lock()in mgcp_chan.c has a coding error in two locations that prevent the subchannel from being found on non-dynamic gateways. This results in responses from half the gateways to be ignored. I built Asterisk from source on a Fedora 14 system. Here is the C code in question from Asterisk version 1.8.3.2:
{code}
for (g = gateways ? gateways : find_realtime_gw(name, at, sin);
g; g = g->next ? g->next : find_realtime_gw(name, at, sin)) {
[lines omitted]
/* not dynamic, check if the name matches */
} else if (name) {
if (strcasecmp(g->name, at)) {
>>>> error >>>> g = g->next;
continue;
}
/* not dynamic, no name, check if the addr matches */
} else if (!name && sin) {
if ((g->addr.sin_addr.s_addr !=
sin->sin_addr.s_addr) ||
(g->addr.sin_port != sin->sin_port)) {
>>>> error >>>> if(!g->next)
>>>> error >>>> g = find_realtime_gw(name, at, sin);
>>>> error >>>> else
>>>> error >>>> g = g->next;
continue;
}
} else {
continue;
}
{code}
Since the "for" statement includes updating "g" from "g->next", the extra updates to "g" in the code above cause gateway entries to be skipped and responses from those gateways to continually exceed the maximum retry count.
I hope this helps!
Jeff Waltz
****** ADDITIONAL INFORMATION ******
I just downloaded the source for 1.8.4 and the erroneous code is still present.
was:
The function find_subchannel_and_lock()in mgcp_chan.c has a coding error in two locations that prevent the subchannel from being found on non-dynamic gateways. This results in responses from half the gateways to be ignored. I built Asterisk from source on a Fedora 14 system. Here is the C code in question from Asterisk version 1.8.3.2:
for (g = gateways ? gateways : find_realtime_gw(name, at, sin);
g; g = g->next ? g->next : find_realtime_gw(name, at, sin)) {
[lines omitted]
/* not dynamic, check if the name matches */
} else if (name) {
if (strcasecmp(g->name, at)) {
>>>> error >>>> g = g->next;
continue;
}
/* not dynamic, no name, check if the addr matches */
} else if (!name && sin) {
if ((g->addr.sin_addr.s_addr !=
sin->sin_addr.s_addr) ||
(g->addr.sin_port != sin->sin_port)) {
>>>> error >>>> if(!g->next)
>>>> error >>>> g = find_realtime_gw(name, at, sin);
>>>> error >>>> else
>>>> error >>>> g = g->next;
continue;
}
} else {
continue;
}
Since the "for" statement includes updating "g" from "g->next", the extra updates to "g" in the code above cause gateway entries to be skipped and responses from those gateways to continually exceed the maximum retry count.
I hope this helps!
Jeff Waltz
****** ADDITIONAL INFORMATION ******
I just downloaded the source for 1.8.4 and the erroneous code is still present.
> Coding error in find_subchannel_and_lock()
> ------------------------------------------
>
> Key: ASTERISK-17797
> URL: https://issues.asterisk.org/jira/browse/ASTERISK-17797
> Project: Asterisk
> Issue Type: Bug
> Components: Channels/chan_mgcp
> Affects Versions: 1.8.3
> Reporter: Jeff Waltz
> Severity: Minor
>
> The function find_subchannel_and_lock()in mgcp_chan.c has a coding error in two locations that prevent the subchannel from being found on non-dynamic gateways. This results in responses from half the gateways to be ignored. I built Asterisk from source on a Fedora 14 system. Here is the C code in question from Asterisk version 1.8.3.2:
> {code}
> for (g = gateways ? gateways : find_realtime_gw(name, at, sin);
> g; g = g->next ? g->next : find_realtime_gw(name, at, sin)) {
> [lines omitted]
> /* not dynamic, check if the name matches */
> } else if (name) {
> if (strcasecmp(g->name, at)) {
> >>>> error >>>> g = g->next;
> continue;
> }
> /* not dynamic, no name, check if the addr matches */
> } else if (!name && sin) {
> if ((g->addr.sin_addr.s_addr !=
> sin->sin_addr.s_addr) ||
> (g->addr.sin_port != sin->sin_port)) {
> >>>> error >>>> if(!g->next)
> >>>> error >>>> g = find_realtime_gw(name, at, sin);
> >>>> error >>>> else
> >>>> error >>>> g = g->next;
> continue;
> }
> } else {
> continue;
> }
> {code}
> Since the "for" statement includes updating "g" from "g->next", the extra updates to "g" in the code above cause gateway entries to be skipped and responses from those gateways to continually exceed the maximum retry count.
> I hope this helps!
> Jeff Waltz
> ****** ADDITIONAL INFORMATION ******
> I just downloaded the source for 1.8.4 and the erroneous code is still present.
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira
More information about the asterisk-bugs
mailing list