Menu

#81 OTC_ServiceBinding incorrectly detects IP vs. hostname

open
ose-7.0 (68)
5
2007-11-16
2007-11-16
No

In the constructor of OTC_ServiceBinding, the receiver name is passed as a string containing colon-delimited fields. There is no way for OTC_ServiceBinding to know whether the host field is a text-encoded hex IP address or simply the string of the machine's configured hostname. So, it uses the istream "hex" operator and checks the fail bit.

If the fail bit is set, then the assumption is that this was a hostname string, and not a hex value. Likewise, if the fail bit is not set, it is assumed to be parseable hex. However, because the colon character is parsed out by calling .ignore(1) on the stream, various likely hostnames can be misinterpreted.

For instance, the hostname "bm32" is interpreted as the hex IP "b" because istream will parse as much as it can without setting the fail bit. Then the "m" is ignored, and "32" is interpreted to be the PID. This has the eventual effect that all generated events will be wrapped in an envelope that incorrectly identifies the source host and PID of the event.

This will occur whenever the hostname can be interpreted as two text-encoded hex values separated by a non-hex character, and WinSock was not initialized before the first call to OTC_Program::uniqueId().

Discussion


Log in to post a comment.