Skip to content

stream_socket_get_name() can return ipv6 address even when ipv6 is not available #16117

Closed as not planned

Description

@ndossche

Description

See #16115 (comment)

PHP Version

PHP 8.4, perhaps lower too

Operating System

Linux

Activity

  1. NattyNarwhal commented on Sep 30, 2024

    @NattyNarwhal
    Member

    I chased the code path since I was looking at PHP network stuff a bit ago, and it (through a ton of indirection) basically just does getsockname then calls inet_ntop on it based on the returned sockaddr's address family. There's not much additional smarts in that code path other than getting the underlying socket fd for the stream. I'm feeling this might be DNS. Probably, it resolves localhost as ::1 and tries making the socket and connecting to that, even if (for some reason) it can't.

  2. added theissue type on Feb 5, 2025
  3. bukka commented on Jun 21, 2025

    @bukka
    Member

    I just had a look and it's like @NattyNarwhal said. It seems to me like an issue with the system resolver or more it's configuration - in the pipeline case possible related to virtualization setup. I have no idea what we could do about this and don't really think this should be addressed in PHP. Or at least I cannot thing about any reasonable solution. As such I'm going to close this but if anyone has some reasonable idea what to do here, happy to re-open it.

  4. bukka commented on Jun 21, 2025

    @bukka
    Member

    Hmm the OP says that it returned ::1 but that's really strange becuase IPv6 is in brackets and that should be only on systems supporting IPv6 (check for HAVE_IPV6) so it would need to somehow return it from IPv4 family.

    This certainly need more info about how to recreate and note what the exact output is.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions