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

socket_getsockname returns wrong address on some unix filename #13603

Closed
jyxjjj opened this issue Mar 6, 2024 · 0 comments
Closed

socket_getsockname returns wrong address on some unix filename #13603

jyxjjj opened this issue Mar 6, 2024 · 0 comments

Comments

@jyxjjj
Copy link

jyxjjj commented Mar 6, 2024

Description

The following code:

<?php
        $socket = socket_create(AF_UNIX, SOCK_STREAM, 0);
        socket_bind($socket, 'sn.sock');
        socket_listen($socket);
        socket_getsockname($socket, $address);

Resulted in this output:

sn.sockxxxxxxxx

But I expected this output instead:

sn.sock

There are more binary string when named as sn.sock
(So i will give it all in hex)
something like this in hex: 58b30101
changed every time when re-generate sn.sock: 98f6(strange, this time it only 4 length)

When a.sock: 9098c10301 90d8800101
s.sock: 90186a0301
(changed every time too)

At first i think it is because this string is too short,
Then i tried s.s, it always returned s.s correctly.

I am using 8.3.1 , I haven't done any more testing, but I have the impression that I met this a long time ago, when I was still a newbie. Seems like from PHP5. I don't have such old env, cannot give more test, sorry

PHP Version

8.3.1

Operating System

macOS 14.2.1 23C71

@devnexen devnexen self-assigned this Mar 6, 2024
devnexen added a commit to devnexen/php-src that referenced this issue Mar 6, 2024
Led to random characters visible on socket id on macOs.
devnexen added a commit to devnexen/php-src that referenced this issue Mar 6, 2024
Led to random characters visible on socket id on macOs.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants