From:             [EMAIL PROTECTED]
Operating system: Solaris 6
PHP version:      4CVS-2002-09-19
PHP Bug Type:     Sockets related
Bug description:  Broken Implementation of local sockaddr_storage

The current implementation of sockaddr_storage in main/php_network.h when
an OS version is not available breaks  word alignment of the structure.
This showed up when compiling php w/ Sun Workshop Pro 4 & Forte 6 rather
than gcc. A SIGBUG would occur when I was testing the ext/ftp extension.

RFC2553's reference implementation put the max padding size at 128, which
is also the size that fixed the problem in my tests. Here is a patch based
off of today's cvs. I've also put in a check for sockaddr.sa_len into
configure.in so the implementation of sockaddr_storage can vary. Though
I'm not completely sure the padding is always correct when sa_len is
found, as I dont have access to a system in that situation, but this is a
step in the right direction if not the fix.  

          Phil.

Index: configure.in
===================================================================
RCS file: /repository/php4/configure.in,v
retrieving revision 1.372
diff -r1.372 configure.in
407a408,416
> dnl Check if sockaddr data structure includes a "sa_len"
> AC_CHECK_MEMBER([struct sockaddr.sa_len],
>                 [ AC_DEFINE(HAVE_SOCKADDR_LEN,1,[Whether sockaddr struct
has sa_len]) ],
>                 [],
>                 [
> #include <sys/types.h>
> #include <sys/socket.h>
> ])
>
Index: main/php_network.h
===================================================================
RCS file: /repository/php4/main/php_network.h,v
retrieving revision 1.27
diff -r1.27 php_network.h
87a88,91
> # ifdef HAVE_SOCKADDR_LEN
>         unsigned char ss_len;
>         unsigned char ss_family;
> # else
89c93,94
<         char info[256];
---
> # endif
>         char info[126];


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

Reply via email to