Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ACE_INET_Addr::set errantly succeeds when ACE_LACKS_GETSERVBYNAME #2080

Merged
merged 1 commit into from
Jun 27, 2023

Conversation

jrw972
Copy link
Contributor

@jrw972 jrw972 commented Jun 21, 2023

Problem

Calling set("1.2.3.4") on an ACE_INET_Addr eventually tries to part it as a port name. When ACE_LACKS_GETSERVBYNAME, this succeeds returning port number 0 with the reset address.

When port names are not expected, this breaks a useful idiom of parsing addresses that may or may not contain port numbers:

ACE_INET_Addr addr;
if (addr.set(x) == 0) {
  // Success, address contained a port number
} else if (addr.set(u_short(0), x) == 0) {
  // Success, address did not contain a port number.
} else {
  // Fail
}

Solution

Return -1 for the port number when ACE_LACKS_GETSERVBYNAME.

mitza-oci
mitza-oci previously approved these changes Jun 21, 2023
@jwillemsen
Copy link
Member

Can you extend a unit test for this?

Problem
-------

Calling `set("1.2.3.4")` on an ACE_INET_Addr eventually tries to part
it as a port name.  When `ACE_LACKS_GETSERVBYNAME`, this succeeds
returning port number 0 with the reset address.

When port names are not expected, this breaks a useful idiom of
parsing addresses that may or may not contain port numbers:

    ACE_INET_Addr addr;
    if (addr.set(x) == 0) {
      // Success, address contained a port number
    } else if (addr.set(u_short(0), x) == 0) {
      // Success, address did not contain a port number.
    } else {
      // Fail
    }

Solution
--------

Return -1 for the port number when `ACE_LACKS_GETSERVBYNAME`.
@jrw972 jrw972 force-pushed the port0-ace-lacks-getservbyname branch from 0230ace to 395f5e5 Compare June 22, 2023 18:44
@jrw972 jrw972 merged commit a65d91c into DOCGroup:master Jun 27, 2023
41 checks passed
mitza-oci pushed a commit to mitza-oci/ACE_TAO that referenced this pull request Jun 27, 2023
…yname

`ACE_INET_Addr::set` errantly succeeds when ACE_LACKS_GETSERVBYNAME

(cherry picked from commit a65d91c)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

4 participants