ID:               38687
 Updated by:       [EMAIL PROTECTED]
 Reported By:      christian dot schuster at s2000 dot tu-chemnitz dot de
-Status:           Open
+Status:           Feedback
 Bug Type:         Streams related
 Operating System: Linux
 PHP Version:      5CVS-2006-09-01 (CVS)
 New Comment:

Thank you for this bug report. To properly diagnose the problem, we
need a short but complete example script to be able to reproduce
this bug ourselves. 

A proper reproducing script starts with <?php and ends with ?>,
is max. 10-20 lines long and does not require any external 
resources such as databases, etc. If the script requires a 
database to demonstrate the issue, please make sure it creates 
all necessary tables, stored procedures etc.

Please avoid embedding huge scripts into the report.




Previous Comments:
------------------------------------------------------------------------

[2006-09-02 00:01:24] christian dot schuster at s2000 dot tu-chemnitz
dot de

Description:
------------
Using stream_socket_client() with a context containing a valid local
IPv6 binding address does not actually bind the socket to that address,
but fails silently. This is a "side effect" of a possible buffer
overflow:

In main/network.c, php_network_connect_socket_to_host() uses a "struct
sockaddr", and references it via a pointer to "struct sockaddr_in" or
"struct sockaddr_in6". For IPv4, this is usually sufficient - for IPv6
it is not. Upon the subsequent call to inet_pton(), some memory beyond
the "struct sockaddr" is accessed.

A "struct sockaddr_in" or "struct sockaddr_in6" should be used instead,
depending on the protocol.

PHP6 is affected by this bug, too.

Proposed patch:
http://www-user.tu-chemnitz.de/~chschu/patches/php-stream_socket_client-bind.patch


Reproduce code:
---------------
/* sample code for illegal use of struct sockaddr */

#include <sys/types.h>
#include <sys/socket.h>
#include <arpa/inet.h>

int main(int, char**) {
        struct sockaddr local_address;
        struct sockaddr_in6 *in6 = (struct sockaddr_in6*)&local_address;
        inet_pton(AF_INET6, "::1", &in6->sin6_addr);
}


Expected result:
----------------
Normal program termination.

Actual result:
--------------
"Segmentation fault" on inet_pton().


------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=38687&edit=1

Reply via email to