From:             [EMAIL PROTECTED]
Operating system: any
PHP version:      4.0.6
PHP Bug Type:     Sockets related
Bug description:  fsockopen can't handle unix sockets created in abstract namespace

fsockopen can't handle unix sockets created in abstract namespace (unix
sockets with the associated pathname starting with '\0'; see UNIX(4) of
the 'Linux Programmer's Manual' for details).

This bug is 'caused since the implementation of fsockopen in PHP 4.0.6
uses strlcpy to copy from $hostname to  unix_addr.sun_path without looking
at the first byte of $hostname (fsock.c, line 240). One possible solution
would be to change line 240 from

strlcpy(unix_addr.sun_path, (*args[0])->value.str.val,
        sizeof(unix_addr.sun_path));

to

pathofs = ((*args[0])->value.str.val[0] ? 0 : 1);
strlcpy(unix_addr.sun_path + pathofs, 
        (*args[0])->value.str.val + pathofs,
        sizeof(unix_addr.sun_path) - pathofs);

where pathofs would be of type "size_t".

Another solution avoiding the ugly '\0' byte would be to introduce
separate scheme prefixes like "file:" and "abstract:" for UNIX domain
sockets.

Ciao,
Mathias
-- 
Edit bug report at http://bugs.php.net/?id=16121&edit=1
-- 
Fixed in CVS:        http://bugs.php.net/fix.php?id=16121&r=fixedcvs
Fixed in release:    http://bugs.php.net/fix.php?id=16121&r=alreadyfixed
Need backtrace:      http://bugs.php.net/fix.php?id=16121&r=needtrace
Try newer version:   http://bugs.php.net/fix.php?id=16121&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=16121&r=support
Expected behavior:   http://bugs.php.net/fix.php?id=16121&r=notwrong
Not enough info:     http://bugs.php.net/fix.php?id=16121&r=notenoughinfo
Submitted twice:     http://bugs.php.net/fix.php?id=16121&r=submittedtwice

Reply via email to