[Ace-users] [tao-bugs] TAO_UIPMC_Endpoint::is_equivalent is broken
Daniel de Angelis Cordeiro
dcordeiro at gmail.com
Fri Jul 20 11:57:28 CDT 2007
TAO VERSION: 1.5.9
ACE VERSION: 5.5.9
HOST MACHINE and OPERATING SYSTEM:
$ uname -a
Linux 2.6.20-16-generic #2 SMP Thu Jun 7 20:19:32 UTC 2007 i686 GNU/Linux
Class UIPMC_Endpoint and the multicast module are affected
Function 'TAO_UIPMC_Endpoint::is_equivalent' always returns true if
the two endpoints being compared have the same port.
The function 'TAO_UIPMC_Endpoint::is_equivalent' defines two endpoints
as equal if they satisfies the following expression:
(this->port_ == endpoint->port_
&& ACE_OS::strcmp (this->get_host_addr (),
endpoint->get_host_addr ()) == 0);
get_host_addr() calls the method ACE_INET_Addr::get_host_addr() that
returns the result of a call to ACE_OS::inet_ntoa().
The manpage of inet_ntoa() says that the function returns a char * to
a static region to the memory and that subsequent calls overwrite the
contents of this region.
So, if the two ports are equal, the strcmp function will receive the
same pointer as arguments and will always return 0.
As consequence, when the GOA calls TAO_GOA::create_group_acceptors,
the TAO_PortableGroup_Acceptor_Registry does not create more than one
acceptor for each port and the acceptor for new multicast addresses
are not created.
This bug was introduced in commit 78280, when the use of the variable
char *class_d_address_ was deprecated. Before that, a copy of the
string returned by inet_ntoa() was stored in the class_d_address and
this copy was used to do the comparison.
Use TAO_UIPMC_Endpoint::addr_to_string() to create the "stringfied"
version of the IP and use it to compare the endpoints.
More information about the Ace-users