#19508 [Opn]: Broken Implementation of local sockaddr_storage

From: Date: Thu, 19 Sep 2002 22:41:55 +0000
Subject: #19508 [Opn]: Broken Implementation of local sockaddr_storage
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-19803@lists.php.net to get a copy of this message
ID: 19508 User updated by: poleson@verio.net Reported By: poleson@verio.net Status: Open Bug Type: Sockets related Operating System: Solaris 6 PHP Version: 4CVS-2002-09-19 New Comment: Bah.. forgot one of my patches.. I believe the following patch is also needed. RCS file: /repository/php4/main/network.c,v retrieving revision 1.66 diff -r1.66 network.c 505c505 < sin->sin_addr.s_addr = INADDR_ANY; --- > sin->sin_addr.s_addr = htonl(INADDR_ANY); Previous Comments: ------------------------------------------------------------------------ [2002-09-19 17:36:38] poleson@verio.net This is buggy in 4.2.3 as well as in CVS ------------------------------------------------------------------------ [2002-09-19 17:22:43] poleson@verio.net 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 this bug report at http://bugs.php.net/?id=19508&edit=1

« previous php.bugs (#19803) next »