php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #19508 Broken Implementation of local sockaddr_storage
Submitted: 2002-09-19 17:22 UTC Modified: 2002-10-29 09:01 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: poleson at verio dot net Assigned: wez (profile)
Status: Closed Package: Sockets related
PHP Version: 4CVS-2002-09-19 OS: Solaris 6
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: poleson at verio dot net
New email:
PHP Version: OS:

 

 [2002-09-19 17:22 UTC] poleson at verio dot 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];


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-09-19 17:36 UTC] poleson at verio dot net
This is buggy in 4.2.3 as well as in CVS
 [2002-09-19 17:41 UTC] poleson at verio dot net
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);
 [2002-09-20 02:56 UTC] wez@php.net
I'll apply your patches this weekend.
 [2002-10-29 09:01 UTC] wez@php.net
Patch applied to CVS - thanks!
(sorry for the delay; the auto reminder system doesn't appear to be working).
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 20:01:29 2024 UTC