[PHP-CVS] cvs: php-src /main network.c

2009-05-04 Thread Antony Dovgal
tony2001Mon May  4 14:44:24 2009 UTC

  Modified files:  
/php-src/main   network.c 
  Log:
  use correct function
  
  
http://cvs.php.net/viewvc.cgi/php-src/main/network.c?r1=1.144&r2=1.145&diff_format=u
Index: php-src/main/network.c
diff -u php-src/main/network.c:1.144 php-src/main/network.c:1.145
--- php-src/main/network.c:1.144Mon May  4 14:25:04 2009
+++ php-src/main/network.c  Mon May  4 14:44:24 2009
@@ -17,7 +17,7 @@
+--+
  */
 
-/* $Id: network.c,v 1.144 2009/05/04 14:25:04 tony2001 Exp $ */
+/* $Id: network.c,v 1.145 2009/05/04 14:44:24 tony2001 Exp $ */
 
 /*#define DEBUG_MAIN_NETWORK 1*/
 
@@ -792,7 +792,7 @@
switch (sa->sa_family) {
 #if HAVE_GETADDRINFO && HAVE_IPV6
case AF_INET6:
-   if (bindto && strstr(bindto, ':')) {
+   if (bindto && strchr(bindto, ':')) {
((struct sockaddr_in6 
*)sa)->sin6_family = sa->sa_family;
((struct sockaddr_in6 *)sa)->sin6_port 
= htons(port);
socklen = sizeof(struct sockaddr_in6);



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src /main network.c

2009-05-04 Thread Antony Dovgal
tony2001Mon May  4 14:25:04 2009 UTC

  Modified files:  
/php-src/main   network.c 
  Log:
  don't segfault on bindto == NULL
  
  
http://cvs.php.net/viewvc.cgi/php-src/main/network.c?r1=1.143&r2=1.144&diff_format=u
Index: php-src/main/network.c
diff -u php-src/main/network.c:1.143 php-src/main/network.c:1.144
--- php-src/main/network.c:1.143Mon May  4 13:12:53 2009
+++ php-src/main/network.c  Mon May  4 14:25:04 2009
@@ -17,7 +17,7 @@
+--+
  */
 
-/* $Id: network.c,v 1.143 2009/05/04 13:12:53 iliaa Exp $ */
+/* $Id: network.c,v 1.144 2009/05/04 14:25:04 tony2001 Exp $ */
 
 /*#define DEBUG_MAIN_NETWORK 1*/
 
@@ -792,7 +792,7 @@
switch (sa->sa_family) {
 #if HAVE_GETADDRINFO && HAVE_IPV6
case AF_INET6:
-   if (strstr(bindto, ':')) {
+   if (bindto && strstr(bindto, ':')) {
((struct sockaddr_in6 
*)sa)->sin6_family = sa->sa_family;
((struct sockaddr_in6 *)sa)->sin6_port 
= htons(port);
socklen = sizeof(struct sockaddr_in6);



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src /main network.c

2009-05-04 Thread Ilia Alshanetsky
iliaa   Mon May  4 13:12:53 2009 UTC

  Modified files:  
/php-src/main   network.c 
  Log:
  
  MFB: Fixed bug #48131 (Don't try to bind ipv4 addresses to ipv6 ips via
  bindto)
  
http://cvs.php.net/viewvc.cgi/php-src/main/network.c?r1=1.142&r2=1.143&diff_format=u
Index: php-src/main/network.c
diff -u php-src/main/network.c:1.142 php-src/main/network.c:1.143
--- php-src/main/network.c:1.142Tue Mar 10 23:39:53 2009
+++ php-src/main/network.c  Mon May  4 13:12:53 2009
@@ -17,7 +17,7 @@
+--+
  */
 
-/* $Id: network.c,v 1.142 2009/03/10 23:39:53 helly Exp $ */
+/* $Id: network.c,v 1.143 2009/05/04 13:12:53 iliaa Exp $ */
 
 /*#define DEBUG_MAIN_NETWORK 1*/
 
@@ -792,9 +792,14 @@
switch (sa->sa_family) {
 #if HAVE_GETADDRINFO && HAVE_IPV6
case AF_INET6:
-   ((struct sockaddr_in6 *)sa)->sin6_family = 
sa->sa_family;
-   ((struct sockaddr_in6 *)sa)->sin6_port = 
htons(port);
-   socklen = sizeof(struct sockaddr_in6);
+   if (strstr(bindto, ':')) {
+   ((struct sockaddr_in6 
*)sa)->sin6_family = sa->sa_family;
+   ((struct sockaddr_in6 *)sa)->sin6_port 
= htons(port);
+   socklen = sizeof(struct sockaddr_in6);
+   } else {
+   socklen = 0;
+   sa = NULL;
+   }
break;
 #endif
case AF_INET:



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src /main network.c

2009-01-02 Thread Felipe Pena
felipe  Sat Jan  3 00:05:53 2009 UTC

  Modified files:  
/php-src/main   network.c 
  Log:
  - Windows part
  
http://cvs.php.net/viewvc.cgi/php-src/main/network.c?r1=1.140&r2=1.141&diff_format=u
Index: php-src/main/network.c
diff -u php-src/main/network.c:1.140 php-src/main/network.c:1.141
--- php-src/main/network.c:1.140Fri Jan  2 21:42:25 2009
+++ php-src/main/network.c  Sat Jan  3 00:05:53 2009
@@ -17,7 +17,7 @@
+--+
  */
 
-/* $Id: network.c,v 1.140 2009/01/02 21:42:25 felipe Exp $ */
+/* $Id: network.c,v 1.141 2009/01/03 00:05:53 felipe Exp $ */
 
 /*#define DEBUG_MAIN_NETWORK 1*/
 
@@ -1147,7 +1147,10 @@
tv.tv_sec = timeout / 1000;
tv.tv_usec = (timeout - (tv.tv_sec * 1000)) * 1000;
}
-#ifndef PHP_WIN32
+/* Reseting/initializing */
+#ifdef PHP_WIN32
+   WSASetLastError(0);
+#else
errno = 0;
 #endif
n = select(max_fd + 1, &rset, &wset, &eset, timeout >= 0 ? &tv : NULL);



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src /main network.c

2009-01-02 Thread Felipe Pena
felipe  Fri Jan  2 21:42:25 2009 UTC

  Modified files:  
/php-src/main   network.c 
  Log:
  - Errr, rule nº 1: be portable :)
  
http://cvs.php.net/viewvc.cgi/php-src/main/network.c?r1=1.139&r2=1.140&diff_format=u
Index: php-src/main/network.c
diff -u php-src/main/network.c:1.139 php-src/main/network.c:1.140
--- php-src/main/network.c:1.139Fri Jan  2 21:26:42 2009
+++ php-src/main/network.c  Fri Jan  2 21:42:25 2009
@@ -17,7 +17,7 @@
+--+
  */
 
-/* $Id: network.c,v 1.139 2009/01/02 21:26:42 felipe Exp $ */
+/* $Id: network.c,v 1.140 2009/01/02 21:42:25 felipe Exp $ */
 
 /*#define DEBUG_MAIN_NETWORK 1*/
 
@@ -1147,7 +1147,9 @@
tv.tv_sec = timeout / 1000;
tv.tv_usec = (timeout - (tv.tv_sec * 1000)) * 1000;
}
+#ifndef PHP_WIN32
errno = 0;
+#endif
n = select(max_fd + 1, &rset, &wset, &eset, timeout >= 0 ? &tv : NULL);
 
if (n >= 0) {



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src /main network.c

2009-01-02 Thread Felipe Pena
felipe  Fri Jan  2 21:26:42 2009 UTC

  Modified files:  
/php-src/main   network.c 
  Log:
  - Working with unintialized errno (#46917, noticed by Jost Boekemeier)
  
http://cvs.php.net/viewvc.cgi/php-src/main/network.c?r1=1.138&r2=1.139&diff_format=u
Index: php-src/main/network.c
diff -u php-src/main/network.c:1.138 php-src/main/network.c:1.139
--- php-src/main/network.c:1.138Wed Dec 31 11:12:38 2008
+++ php-src/main/network.c  Fri Jan  2 21:26:42 2009
@@ -17,7 +17,7 @@
+--+
  */
 
-/* $Id: network.c,v 1.138 2008/12/31 11:12:38 sebastian Exp $ */
+/* $Id: network.c,v 1.139 2009/01/02 21:26:42 felipe Exp $ */
 
 /*#define DEBUG_MAIN_NETWORK 1*/
 
@@ -1147,6 +1147,7 @@
tv.tv_sec = timeout / 1000;
tv.tv_usec = (timeout - (tv.tv_sec * 1000)) * 1000;
}
+   errno = 0;
n = select(max_fd + 1, &rset, &wset, &eset, timeout >= 0 ? &tv : NULL);
 
if (n >= 0) {



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src /main network.c

2008-11-04 Thread Arnaud Le Blanc
lbarnaudTue Nov  4 20:40:04 2008 UTC

  Modified files:  
/php-src/main   network.c 
  Log:
  initialize memory
  
  
http://cvs.php.net/viewvc.cgi/php-src/main/network.c?r1=1.136&r2=1.137&diff_format=u
Index: php-src/main/network.c
diff -u php-src/main/network.c:1.136 php-src/main/network.c:1.137
--- php-src/main/network.c:1.136Fri Oct 24 10:44:19 2008
+++ php-src/main/network.c  Tue Nov  4 20:40:04 2008
@@ -17,7 +17,7 @@
+--+
  */
 
-/* $Id: network.c,v 1.136 2008/10/24 10:44:19 felipe Exp $ */
+/* $Id: network.c,v 1.137 2008/11/04 20:40:04 lbarnaud Exp $ */
 
 /*#define DEBUG_MAIN_NETWORK 1*/
 
@@ -647,6 +647,7 @@
 {
php_sockaddr_storage sa;
socklen_t sl = sizeof(sa);
+   memset(&sa, 0, sizeof(sa));

if (getpeername(sock, (struct sockaddr*)&sa, &sl) == 0) {
php_network_populate_name_from_sockaddr((struct sockaddr*)&sa, 
sl,
@@ -666,6 +667,7 @@
 {
php_sockaddr_storage sa;
socklen_t sl = sizeof(sa);
+   memset(&sa, 0, sizeof(sa));

if (getsockname(sock, (struct sockaddr*)&sa, &sl) == 0) {
php_network_populate_name_from_sockaddr((struct sockaddr*)&sa, 
sl,



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src /main network.c

2008-10-24 Thread Felipe Pena
felipe  Fri Oct 24 10:44:19 2008 UTC

  Modified files:  
/php-src/main   network.c 
  Log:
  - Fixed bug #46082 (stream_set_blocking() can cause a crash in some 
circumstances)
  
http://cvs.php.net/viewvc.cgi/php-src/main/network.c?r1=1.135&r2=1.136&diff_format=u
Index: php-src/main/network.c
diff -u php-src/main/network.c:1.135 php-src/main/network.c:1.136
--- php-src/main/network.c:1.135Thu Aug 21 23:37:40 2008
+++ php-src/main/network.c  Fri Oct 24 10:44:19 2008
@@ -17,7 +17,7 @@
+--+
  */
 
-/* $Id: network.c,v 1.135 2008/08/21 23:37:40 pajoye Exp $ */
+/* $Id: network.c,v 1.136 2008/10/24 10:44:19 felipe Exp $ */
 
 /*#define DEBUG_MAIN_NETWORK 1*/
 
@@ -1057,7 +1057,11 @@
/* with ioctlsocket, a non-zero sets nonblocking, a zero sets blocking 
*/
flags = !block;
if (ioctlsocket(socketd, FIONBIO, &flags) == SOCKET_ERROR) {
-   php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s", 
WSAGetLastError());
+   char *error_string;
+   
+   error_string = php_socket_strerror(WSAGetLastError(), NULL, 0);
+   php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s", error_string);
+   efree(error_string);
ret = FAILURE;
}
 #else



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src /main network.c

2008-07-11 Thread Jani Taskinen
janiFri Jul 11 13:11:37 2008 UTC

  Modified files:  
/php-src/main   network.c 
  Log:
  - Silence "unused variable" warning when ip6 support is disabled
  
http://cvs.php.net/viewvc.cgi/php-src/main/network.c?r1=1.133&r2=1.134&diff_format=u
Index: php-src/main/network.c
diff -u php-src/main/network.c:1.133 php-src/main/network.c:1.134
--- php-src/main/network.c:1.133Tue Mar 11 10:26:51 2008
+++ php-src/main/network.c  Fri Jul 11 13:11:37 2008
@@ -17,7 +17,7 @@
+--+
  */
 
-/* $Id: network.c,v 1.133 2008/03/11 10:26:51 tony2001 Exp $ */
+/* $Id: network.c,v 1.134 2008/07/11 13:11:37 jani Exp $ */
 
 /*#define DEBUG_MAIN_NETWORK 1*/
 
@@ -167,7 +167,9 @@
struct sockaddr **sap;
int n;
 #if HAVE_GETADDRINFO
+# if HAVE_IPV6
static int ipv6_borked = -1; /* the way this is used *is* thread safe */
+# endif
struct addrinfo hints, *res, *sai;
 #else
struct hostent *host_info;



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-CVS] cvs: php-src /main network.c

2008-03-11 Thread Andrey Hristov
Antony Dovgal wrote:
> tony2001  Tue Mar 11 10:26:51 2008 UTC
> 
>   Modified files:  
> /php-src/main network.c 
>   Log:
>   fix segfault - error_string may be NULL, in this case we have to follow the 
> old behavior
>   
>   

Opps, *shame* :)

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src /main network.c

2008-03-11 Thread Antony Dovgal
tony2001Tue Mar 11 10:26:51 2008 UTC

  Modified files:  
/php-src/main   network.c 
  Log:
  fix segfault - error_string may be NULL, in this case we have to follow the 
old behavior
  
  
http://cvs.php.net/viewvc.cgi/php-src/main/network.c?r1=1.132&r2=1.133&diff_format=u
Index: php-src/main/network.c
diff -u php-src/main/network.c:1.132 php-src/main/network.c:1.133
--- php-src/main/network.c:1.132Mon Mar 10 19:55:43 2008
+++ php-src/main/network.c  Tue Mar 11 10:26:51 2008
@@ -17,7 +17,7 @@
+--+
  */
 
-/* $Id: network.c,v 1.132 2008/03/10 19:55:43 andrey Exp $ */
+/* $Id: network.c,v 1.133 2008/03/11 10:26:51 tony2001 Exp $ */
 
 /*#define DEBUG_MAIN_NETWORK 1*/
 
@@ -205,12 +205,20 @@
 # endif

if ((n = getaddrinfo(host, NULL, &hints, &res))) {
-   spprintf(error_string, 0, "php_network_getaddresses: 
getaddrinfo failed: %s", PHP_GAI_STRERROR(n));
-   php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s", 
*error_string);
+   if (error_string) {
+   spprintf(error_string, 0, "php_network_getaddresses: 
getaddrinfo failed: %s", PHP_GAI_STRERROR(n));
+   php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s", 
*error_string);
+   } else {
+   php_error_docref(NULL TSRMLS_CC, E_WARNING, 
"php_network_getaddresses: getaddrinfo failed: %s", PHP_GAI_STRERROR(n));
+   }
return 0;
} else if (res == NULL) {
-   spprintf(error_string, 0, "php_network_getaddresses: 
getaddrinfo failed (null result pointer) errno=%d", errno);
-   php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s", 
*error_string);
+   if (error_string) {
+   spprintf(error_string, 0, "php_network_getaddresses: 
getaddrinfo failed (null result pointer) errno=%d", errno);
+   php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s", 
*error_string);
+   } else {
+   php_error_docref(NULL TSRMLS_CC, E_WARNING, 
"php_network_getaddresses: getaddrinfo failed (null result pointer)");
+   }
return 0;
}
 
@@ -234,8 +242,12 @@
/* XXX NOT THREAD SAFE (is safe under win32) */
host_info = gethostbyname(host);
if (host_info == NULL) {
-   spprintf(error_string, 0, "php_network_getaddresses: 
gethostbyname failed. errno=%d", errno);
-   php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s", 
*error_string);
+   if (error_string) {
+   spprintf(error_string, 0, 
"php_network_getaddresses: gethostbyname failed. errno=%d", errno);
+   php_error_docref(NULL TSRMLS_CC, E_WARNING, 
"%s", *error_string);
+   } else {
+   php_error_docref(NULL TSRMLS_CC, E_WARNING, 
"php_network_getaddresses: gethostbyname failed");
+   }
return 0;
}
in = *((struct in_addr *) host_info->h_addr);



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src /main network.c /main/streams xp_socket.c

2008-03-10 Thread Andrey Hristov
andrey  Mon Mar 10 19:55:43 2008 UTC

  Modified files:  
/php-src/main   network.c 
/php-src/main/streams   xp_socket.c 
  Log:
char **error_message was passed but not used. This causes problems in cases
of getaddrinfo() failure, because the upper layers don't get the error.
initialize a variable because we were reading initialized in case of error.
  
  
http://cvs.php.net/viewvc.cgi/php-src/main/network.c?r1=1.131&r2=1.132&diff_format=u
Index: php-src/main/network.c
diff -u php-src/main/network.c:1.131 php-src/main/network.c:1.132
--- php-src/main/network.c:1.131Mon Dec 31 07:12:18 2007
+++ php-src/main/network.c  Mon Mar 10 19:55:43 2008
@@ -17,7 +17,7 @@
+--+
  */
 
-/* $Id: network.c,v 1.131 2007/12/31 07:12:18 sebastian Exp $ */
+/* $Id: network.c,v 1.132 2008/03/10 19:55:43 andrey Exp $ */
 
 /*#define DEBUG_MAIN_NETWORK 1*/
 
@@ -205,10 +205,12 @@
 # endif

if ((n = getaddrinfo(host, NULL, &hints, &res))) {
-   php_error_docref(NULL TSRMLS_CC, E_WARNING, 
"php_network_getaddresses: getaddrinfo failed: %s", PHP_GAI_STRERROR(n));
+   spprintf(error_string, 0, "php_network_getaddresses: 
getaddrinfo failed: %s", PHP_GAI_STRERROR(n));
+   php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s", 
*error_string);
return 0;
} else if (res == NULL) {
-   php_error_docref(NULL TSRMLS_CC, E_WARNING, 
"php_network_getaddresses: getaddrinfo failed (null result pointer)");
+   spprintf(error_string, 0, "php_network_getaddresses: 
getaddrinfo failed (null result pointer) errno=%d", errno);
+   php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s", 
*error_string);
return 0;
}
 
@@ -232,7 +234,8 @@
/* XXX NOT THREAD SAFE (is safe under win32) */
host_info = gethostbyname(host);
if (host_info == NULL) {
-   php_error_docref(NULL TSRMLS_CC, E_WARNING, 
"php_network_getaddresses: gethostbyname failed");
+   spprintf(error_string, 0, "php_network_getaddresses: 
gethostbyname failed. errno=%d", errno);
+   php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s", 
*error_string);
return 0;
}
in = *((struct in_addr *) host_info->h_addr);
http://cvs.php.net/viewvc.cgi/php-src/main/streams/xp_socket.c?r1=1.44&r2=1.45&diff_format=u
Index: php-src/main/streams/xp_socket.c
diff -u php-src/main/streams/xp_socket.c:1.44 
php-src/main/streams/xp_socket.c:1.45
--- php-src/main/streams/xp_socket.c:1.44   Wed Feb 27 00:30:49 2008
+++ php-src/main/streams/xp_socket.cMon Mar 10 19:55:43 2008
@@ -16,7 +16,7 @@
   +--+
 */
 
-/* $Id: xp_socket.c,v 1.44 2008/02/27 00:30:49 iliaa Exp $ */
+/* $Id: xp_socket.c,v 1.45 2008/03/10 19:55:43 andrey Exp $ */
 
 #include "php.h"
 #include "ext/standard/file.h"
@@ -601,7 +601,7 @@
 {
char *host = NULL, *bindto = NULL;
int portno, bindport = 0;
-   int err;
+   int err = 0;
int ret;
zval **tmpzval = NULL;
 



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src /main network.c

2007-11-06 Thread Rob Richards
rrichards   Tue Nov  6 10:56:53 2007 UTC

  Modified files:  
/php-src/main   network.c 
  Log:
  fix non ipv6 enabled win build
  
http://cvs.php.net/viewvc.cgi/php-src/main/network.c?r1=1.129&r2=1.130&diff_format=u
Index: php-src/main/network.c
diff -u php-src/main/network.c:1.129 php-src/main/network.c:1.130
--- php-src/main/network.c:1.129Fri Oct 12 08:08:02 2007
+++ php-src/main/network.c  Tue Nov  6 10:56:53 2007
@@ -17,7 +17,7 @@
+--+
  */
 
-/* $Id: network.c,v 1.129 2007/10/12 08:08:02 edink Exp $ */
+/* $Id: network.c,v 1.130 2007/11/06 10:56:53 rrichards Exp $ */
 
 /*#define DEBUG_MAIN_NETWORK 1*/
 
@@ -91,7 +91,9 @@
 # define SOCK_CONN_ERR SOCKET_ERROR
 # define PHP_TIMEOUT_ERROR_VALUE   WSAETIMEDOUT
 
+#if HAVE_IPV6
 const struct in6_addr in6addr_any = {0}; /* IN6ADDR_ANY_INIT; */
+#endif
 
 #else
 # define SOCK_ERR -1

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src /main network.c

2007-10-12 Thread Edin Kadribasic
edink   Fri Oct 12 08:08:02 2007 UTC

  Modified files:  
/php-src/main   network.c 
  Log:
  MFB: Fix build
  
http://cvs.php.net/viewvc.cgi/php-src/main/network.c?r1=1.128&r2=1.129&diff_format=u
Index: php-src/main/network.c
diff -u php-src/main/network.c:1.128 php-src/main/network.c:1.129
--- php-src/main/network.c:1.128Wed Oct 10 23:23:54 2007
+++ php-src/main/network.c  Fri Oct 12 08:08:02 2007
@@ -17,7 +17,7 @@
+--+
  */
 
-/* $Id: network.c,v 1.128 2007/10/10 23:23:54 auroraeosrose Exp $ */
+/* $Id: network.c,v 1.129 2007/10/12 08:08:02 edink Exp $ */
 
 /*#define DEBUG_MAIN_NETWORK 1*/
 
@@ -91,7 +91,7 @@
 # define SOCK_CONN_ERR SOCKET_ERROR
 # define PHP_TIMEOUT_ERROR_VALUE   WSAETIMEDOUT
 
-struct in6_addr in6addr_any = {0}; /* IN6ADDR_ANY_INIT; */
+const struct in6_addr in6addr_any = {0}; /* IN6ADDR_ANY_INIT; */
 
 #else
 # define SOCK_ERR -1

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src /main network.c php_network.h

2007-10-10 Thread Elizabeth Marie Smith
auroraeosrose   Wed Oct 10 23:23:54 2007 UTC

  Modified files:  
/php-src/main   network.c php_network.h 
  Log:
  MFB
  
http://cvs.php.net/viewvc.cgi/php-src/main/network.c?r1=1.127&r2=1.128&diff_format=u
Index: php-src/main/network.c
diff -u php-src/main/network.c:1.127 php-src/main/network.c:1.128
--- php-src/main/network.c:1.127Wed Jul 18 09:04:37 2007
+++ php-src/main/network.c  Wed Oct 10 23:23:54 2007
@@ -17,7 +17,7 @@
+--+
  */
 
-/* $Id: network.c,v 1.127 2007/07/18 09:04:37 jani Exp $ */
+/* $Id: network.c,v 1.128 2007/10/10 23:23:54 auroraeosrose Exp $ */
 
 /*#define DEBUG_MAIN_NETWORK 1*/
 
@@ -90,6 +90,9 @@
 # define SOCK_ERR INVALID_SOCKET
 # define SOCK_CONN_ERR SOCKET_ERROR
 # define PHP_TIMEOUT_ERROR_VALUE   WSAETIMEDOUT
+
+struct in6_addr in6addr_any = {0}; /* IN6ADDR_ANY_INIT; */
+
 #else
 # define SOCK_ERR -1
 # define SOCK_CONN_ERR -1
http://cvs.php.net/viewvc.cgi/php-src/main/php_network.h?r1=1.58&r2=1.59&diff_format=u
Index: php-src/main/php_network.h
diff -u php-src/main/php_network.h:1.58 php-src/main/php_network.h:1.59
--- php-src/main/php_network.h:1.58 Mon Jan  1 09:29:35 2007
+++ php-src/main/php_network.h  Wed Oct 10 23:23:54 2007
@@ -16,7 +16,7 @@
+--+
  */
 
-/* $Id: php_network.h,v 1.58 2007/01/01 09:29:35 sebastian Exp $ */
+/* $Id: php_network.h,v 1.59 2007/10/10 23:23:54 auroraeosrose Exp $ */
 
 #ifndef _PHP_NETWORK_H
 #define _PHP_NETWORK_H
@@ -121,12 +121,14 @@
 
 PHPAPI int php_poll2(php_pollfd *ufds, unsigned int nfds, int timeout);
 
+#ifndef POLLIN
 # define POLLIN  0x0001/* There is data to read */
 # define POLLPRI 0x0002/* There is urgent data to read */
 # define POLLOUT 0x0004/* Writing now will not block */
 # define POLLERR 0x0008/* Error condition */
 # define POLLHUP 0x0010/* Hung up */
 # define POLLNVAL0x0020/* Invalid request: fd not open */
+#endif
 
 # ifndef PHP_USE_POLL_2_EMULATION
 #  define PHP_USE_POLL_2_EMULATION 1

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src /main network.c

2007-07-18 Thread Jani Taskinen
janiWed Jul 18 09:04:38 2007 UTC

  Modified files:  
/php-src/main   network.c 
  Log:
  - Use correct macro name
  
http://cvs.php.net/viewvc.cgi/php-src/main/network.c?r1=1.126&r2=1.127&diff_format=u
Index: php-src/main/network.c
diff -u php-src/main/network.c:1.126 php-src/main/network.c:1.127
--- php-src/main/network.c:1.126Tue Jul 17 13:29:25 2007
+++ php-src/main/network.c  Wed Jul 18 09:04:37 2007
@@ -17,7 +17,7 @@
+--+
  */
 
-/* $Id: network.c,v 1.126 2007/07/17 13:29:25 jani Exp $ */
+/* $Id: network.c,v 1.127 2007/07/18 09:04:37 jani Exp $ */
 
 /*#define DEBUG_MAIN_NETWORK 1*/
 
@@ -1035,7 +1035,7 @@
flags = !block;
if (ioctlsocket(socketd, FIONBIO, &flags) == SOCKET_ERROR) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s", 
WSAGetLastError());
-   ret = FALSE;
+   ret = FAILURE;
}
 #else
flags = fcntl(socketd, F_GETFL);

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src /main network.c

2007-07-17 Thread Jani Taskinen
janiTue Jul 17 13:29:25 2007 UTC

  Modified files:  
/php-src/main   network.c 
  Log:
  ws fix
  
http://cvs.php.net/viewvc.cgi/php-src/main/network.c?r1=1.125&r2=1.126&diff_format=u
Index: php-src/main/network.c
diff -u php-src/main/network.c:1.125 php-src/main/network.c:1.126
--- php-src/main/network.c:1.125Thu Jan 11 15:51:29 2007
+++ php-src/main/network.c  Tue Jul 17 13:29:25 2007
@@ -17,7 +17,7 @@
+--+
  */
 
-/* $Id: network.c,v 1.125 2007/01/11 15:51:29 tony2001 Exp $ */
+/* $Id: network.c,v 1.126 2007/07/17 13:29:25 jani Exp $ */
 
 /*#define DEBUG_MAIN_NETWORK 1*/
 
@@ -1026,32 +1026,32 @@
 
 PHPAPI int php_set_sock_blocking(int socketd, int block TSRMLS_DC)
 {
-  int ret = SUCCESS;
-  int flags;
-  int myflag = 0;
+   int ret = SUCCESS;
+   int flags;
+   int myflag = 0;
 
 #ifdef PHP_WIN32
-  /* with ioctlsocket, a non-zero sets nonblocking, a zero sets blocking */
- flags = !block;
- if (ioctlsocket(socketd, FIONBIO, &flags)==SOCKET_ERROR){
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s", 
WSAGetLastError());
- ret = FALSE;
-  }
+   /* with ioctlsocket, a non-zero sets nonblocking, a zero sets blocking 
*/
+   flags = !block;
+   if (ioctlsocket(socketd, FIONBIO, &flags) == SOCKET_ERROR) {
+   php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s", 
WSAGetLastError());
+   ret = FALSE;
+   }
 #else
-  flags = fcntl(socketd, F_GETFL);
+   flags = fcntl(socketd, F_GETFL);
 #ifdef O_NONBLOCK
-  myflag = O_NONBLOCK; /* POSIX version */
+   myflag = O_NONBLOCK; /* POSIX version */
 #elif defined(O_NDELAY)
-  myflag = O_NDELAY;   /* old non-POSIX version */
+   myflag = O_NDELAY;   /* old non-POSIX version */
 #endif
-  if (!block) {
-  flags |= myflag;
-  } else {
+   if (!block) {
+   flags |= myflag;
+   } else {
flags &= ~myflag;
-  }
-  fcntl(socketd, F_SETFL, flags);
+   }
+   fcntl(socketd, F_SETFL, flags);
 #endif
-  return ret;
+   return ret;
 }
 
 PHPAPI void _php_emit_fd_setsize_warning(int max_fd)

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src /main network.c

2007-01-11 Thread Antony Dovgal
tony2001Thu Jan 11 15:51:29 2007 UTC

  Modified files:  
/php-src/main   network.c 
  Log:
  use closesocket() on Win32 and close() on *nix
  
  
http://cvs.php.net/viewvc.cgi/php-src/main/network.c?r1=1.124&r2=1.125&diff_format=u
Index: php-src/main/network.c
diff -u php-src/main/network.c:1.124 php-src/main/network.c:1.125
--- php-src/main/network.c:1.124Mon Jan  1 09:29:35 2007
+++ php-src/main/network.c  Thu Jan 11 15:51:29 2007
@@ -17,7 +17,7 @@
+--+
  */
 
-/* $Id: network.c,v 1.124 2007/01/01 09:29:35 sebastian Exp $ */
+/* $Id: network.c,v 1.125 2007/01/11 15:51:29 tony2001 Exp $ */
 
 /*#define DEBUG_MAIN_NETWORK 1*/
 
@@ -441,7 +441,7 @@
err = php_socket_errno();
}
 
-   close(sock);
+   closesocket(sock);
}
sock = -1;
 
@@ -870,7 +870,7 @@
 #endif
}
 
-   close(sock);
+   closesocket(sock);
}
sock = -1;
 

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src /main network.c

2006-09-11 Thread Sara Golemon
pollita Mon Sep 11 19:18:06 2006 UTC

  Modified files:  
/php-src/main   network.c 
  Log:
  Bug #38687 - sockaddr local storage insufficient for all sock families
  
http://cvs.php.net/viewvc.cgi/php-src/main/network.c?r1=1.122&r2=1.123&diff_format=u
Index: php-src/main/network.c
diff -u php-src/main/network.c:1.122 php-src/main/network.c:1.123
--- php-src/main/network.c:1.122Sat Jul  1 11:50:52 2006
+++ php-src/main/network.c  Mon Sep 11 19:18:06 2006
@@ -17,7 +17,7 @@
+--+
  */
 
-/* $Id: network.c,v 1.122 2006/07/01 11:50:52 nlopess Exp $ */
+/* $Id: network.c,v 1.123 2006/09/11 19:18:06 pollita Exp $ */
 
 /*#define DEBUG_MAIN_NETWORK 1*/
 
@@ -787,37 +787,46 @@
/* make a connection attempt */
 
if (bindto) {
-   struct sockaddr local_address;
-   
+   struct sockaddr *local_address = NULL;
+   int local_address_len = 0;
+   
if (sa->sa_family == AF_INET) {
-   struct sockaddr_in *in4 = (struct 
sockaddr_in*)&local_address;
-   
+   struct sockaddr_in *in4 = 
emalloc(sizeof(struct sockaddr_in));
+
+   local_address = (struct sockaddr*)in4;
+   local_address_len = sizeof(struct 
sockaddr_in);
+
in4->sin_family = sa->sa_family;
in4->sin_port = htons(bindport);
if (!inet_aton(bindto, &in4->sin_addr)) 
{
-   goto bad_ip;
+   php_error_docref(NULL 
TSRMLS_CC, E_WARNING, "Invalid IP Address: %s", bindto);
+   goto skip_bind;
}
memset(&(in4->sin_zero), 0, 
sizeof(in4->sin_zero));
}
 #if HAVE_IPV6 && HAVE_INET_PTON
 else { /* IPV6 */
-   struct sockaddr_in6 *in6 = (struct 
sockaddr_in6*)&local_address;
+   struct sockaddr_in6 *in6 = 
emalloc(sizeof(struct sockaddr_in6));
+
+   local_address = (struct sockaddr*)in6;
+   local_address_len = sizeof(struct 
sockaddr_in6);

in6->sin6_family = sa->sa_family;
in6->sin6_port = htons(bindport);
if (inet_pton(AF_INET6, bindto, 
&in6->sin6_addr) < 1) {
-   goto bad_ip;
+   php_error_docref(NULL 
TSRMLS_CC, E_WARNING, "Invalid IP Address: %s", bindto);
+   goto skip_bind;
}
}
 #endif
-   if (bind(sock, &local_address, sizeof(struct 
sockaddr))) {
+   if (!local_address || bind(sock, local_address, 
local_address_len)) {
php_error_docref(NULL TSRMLS_CC, 
E_WARNING, "failed to bind to '%s:%d', system said: %s", bindto, bindport, 
strerror(errno));
}
-   goto bind_done;
-bad_ip:
-   php_error_docref(NULL TSRMLS_CC, E_WARNING, 
"Invalid IP Address: %s", bindto);
+skip_bind:
+   if (local_address) {
+   efree(local_address);
+   }
}
-bind_done:
/* free error string recieved during previous iteration 
(if any) */
if (error_string && *error_string) {
efree(*error_string);

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src /main network.c

2006-03-19 Thread Antony Dovgal
tony2001Sun Mar 19 22:34:26 2006 UTC

  Modified files:  
/php-src/main   network.c 
  Log:
  MFB: first check stream for NULL, then dereference
  
  
http://cvs.php.net/viewcvs.cgi/php-src/main/network.c?r1=1.120&r2=1.121&diff_format=u
Index: php-src/main/network.c
diff -u php-src/main/network.c:1.120 php-src/main/network.c:1.121
--- php-src/main/network.c:1.120Sun Feb 19 04:29:41 2006
+++ php-src/main/network.c  Sun Mar 19 22:34:26 2006
@@ -17,7 +17,7 @@
+--+
  */
 
-/* $Id: network.c,v 1.120 2006/02/19 04:29:41 andi Exp $ */
+/* $Id: network.c,v 1.121 2006/03/19 22:34:26 tony2001 Exp $ */
 
 /*#define DEBUG_MAIN_NETWORK 1*/
 
@@ -988,10 +988,12 @@
sock->socket = socket;
 
stream = php_stream_alloc_rel(&php_stream_generic_socket_ops, sock, 
persistent_id, "r+");
-   stream->flags |= PHP_STREAM_FLAG_AVOID_BLOCKING;
 
-   if (stream == NULL) 
+   if (stream == NULL) {
pefree(sock, persistent_id ? 1 : 0);
+   } else {
+   stream->flags |= PHP_STREAM_FLAG_AVOID_BLOCKING;
+   }
 
return stream;
 }

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src /main network.c

2005-06-20 Thread Antony Dovgal
tony2001Mon Jun 20 19:16:29 2005 EDT

  Modified files:  
/php-src/main   network.c 
  Log:
  fix memleak when connection fails (and we still keep trying)
  
  
http://cvs.php.net/diff.php/php-src/main/network.c?r1=1.116&r2=1.117&ty=u
Index: php-src/main/network.c
diff -u php-src/main/network.c:1.116 php-src/main/network.c:1.117
--- php-src/main/network.c:1.116Tue Jun 14 09:09:04 2005
+++ php-src/main/network.c  Mon Jun 20 19:16:27 2005
@@ -17,7 +17,7 @@
+--+
  */
 
-/* $Id: network.c,v 1.116 2005/06/14 13:09:04 iliaa Exp $ */
+/* $Id: network.c,v 1.117 2005/06/20 23:16:27 tony2001 Exp $ */
 
 /*#define DEBUG_MAIN_NETWORK 1*/
 
@@ -817,7 +817,13 @@
 bad_ip:
php_error_docref(NULL TSRMLS_CC, E_WARNING, 
"Invalid IP Address: %s", bindto);
}
-bind_done: 
+bind_done:
+   /* free error string recieved during previous iteration 
(if any) */
+   if (error_string && *error_string) {
+   efree(*error_string);
+   *error_string = NULL;
+   }
+   
n = php_network_connect_socket(sock, sa, socklen, 
asynchronous,
timeout ? &working_timeout : NULL,
error_string, error_code);

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-CVS] cvs: php-src /main network.c

2005-06-14 Thread Andi Gutmans

Thanks.

At 01:09 PM 6/14/2005 +, Ilia Alshanetsky wrote:

iliaa   Tue Jun 14 09:09:07 2005 EDT

  Modified files:
/php-src/main   network.c
  Log:
  bzero > memset


http://cvs.php.net/diff.php/php-src/main/network.c?r1=1.115&r2=1.116&ty=u
Index: php-src/main/network.c
diff -u php-src/main/network.c:1.115 php-src/main/network.c:1.116
--- php-src/main/network.c:1.115Mon Jun 13 22:39:42 2005
+++ php-src/main/network.c  Tue Jun 14 09:09:04 2005
@@ -17,7 +17,7 @@
+--+
  */

-/* $Id: network.c,v 1.115 2005/06/14 02:39:42 iliaa Exp $ */
+/* $Id: network.c,v 1.116 2005/06/14 13:09:04 iliaa Exp $ */

 /*#define DEBUG_MAIN_NETWORK 1*/

@@ -797,7 +797,7 @@
if (!inet_aton(bindto, 
&in4->sin_addr)) {

goto bad_ip;
}
-   bzero(&(in4->sin_zero), 8);
+   memset(&(in4->sin_zero), 0, 
sizeof(in4->sin_zero));

}
 #if HAVE_IPV6 && HAVE_INET_PTON
else { /* IPV6 */

--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src /main network.c

2005-06-14 Thread Ilia Alshanetsky
iliaa   Tue Jun 14 09:09:07 2005 EDT

  Modified files:  
/php-src/main   network.c 
  Log:
  bzero > memset
  
  
http://cvs.php.net/diff.php/php-src/main/network.c?r1=1.115&r2=1.116&ty=u
Index: php-src/main/network.c
diff -u php-src/main/network.c:1.115 php-src/main/network.c:1.116
--- php-src/main/network.c:1.115Mon Jun 13 22:39:42 2005
+++ php-src/main/network.c  Tue Jun 14 09:09:04 2005
@@ -17,7 +17,7 @@
+--+
  */
 
-/* $Id: network.c,v 1.115 2005/06/14 02:39:42 iliaa Exp $ */
+/* $Id: network.c,v 1.116 2005/06/14 13:09:04 iliaa Exp $ */
 
 /*#define DEBUG_MAIN_NETWORK 1*/
 
@@ -797,7 +797,7 @@
if (!inet_aton(bindto, &in4->sin_addr)) 
{
goto bad_ip;
}
-   bzero(&(in4->sin_zero), 8);
+   memset(&(in4->sin_zero), 0, 
sizeof(in4->sin_zero));
}
 #if HAVE_IPV6 && HAVE_INET_PTON
 else { /* IPV6 */

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src /main network.c

2004-10-06 Thread Anantha Kesari H Y
hyanantha   Wed Oct  6 09:22:27 2004 EDT

  Modified files:  
/php-src/main   network.c 
  Log:
  removed unwanted NEW_LIBC checks
  
  
http://cvs.php.net/diff.php/php-src/main/network.c?r1=1.113&r2=1.114&ty=u
Index: php-src/main/network.c
diff -u php-src/main/network.c:1.113 php-src/main/network.c:1.114
--- php-src/main/network.c:1.113Fri Sep 17 10:36:54 2004
+++ php-src/main/network.c  Wed Oct  6 09:22:21 2004
@@ -17,7 +17,7 @@
+--+
  */
 
-/* $Id: network.c,v 1.113 2004/09/17 14:36:54 wez Exp $ */
+/* $Id: network.c,v 1.114 2004/10/06 13:22:21 hyanantha Exp $ */
 
 /*#define DEBUG_MAIN_NETWORK 1*/
 
@@ -29,13 +29,9 @@
 #define O_RDONLY _O_RDONLY
 #include "win32/param.h"
 #elif defined(NETWARE)
-#ifdef NEW_LIBC
 #include 
 #include 
 #else
-#include "netware/time_nw.h"
-#endif
-#else
 #include 
 #endif
 
@@ -57,15 +53,12 @@
 
 #if defined(NETWARE)
 #ifdef USE_WINSOCK
-/*#include */
 #include 
 #else
-/* New headers for socket stuff */
-#ifdef NEW_LIBC
+#include 
 #include 
 #include 
 #include 
-#endif
 #include 
 #endif
 #elif !defined(PHP_WIN32)

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src /main network.c /main/streams xp_socket.c /win32/build config.w32

2004-09-17 Thread Wez Furlong
wez Fri Sep 17 10:36:55 2004 EDT

  Modified files:  
/php-src/main   network.c 
/php-src/main/streams   xp_socket.c 
/php-src/win32/buildconfig.w32 
  Log:
  Make new poll stuff work on win32 (and still be safe on unix)
  
  
http://cvs.php.net/diff.php/php-src/main/network.c?r1=1.112&r2=1.113&ty=u
Index: php-src/main/network.c
diff -u php-src/main/network.c:1.112 php-src/main/network.c:1.113
--- php-src/main/network.c:1.112Fri Sep 17 08:44:56 2004
+++ php-src/main/network.c  Fri Sep 17 10:36:54 2004
@@ -17,7 +17,7 @@
+--+
  */
 
-/* $Id: network.c,v 1.112 2004/09/17 12:44:56 wez Exp $ */
+/* $Id: network.c,v 1.113 2004/09/17 14:36:54 wez Exp $ */
 
 /*#define DEBUG_MAIN_NETWORK 1*/
 
@@ -1047,7 +1047,7 @@
php_socket_t max_fd = SOCK_ERR;
unsigned int i, n;
struct timeval tv;
-   
+
/* check the highest numbered descriptor */
for (i = 0; i < nfds; i++) {
if (ufds[i].fd > max_fd)
@@ -1061,19 +1061,14 @@
FD_ZERO(&eset);
 
for (i = 0; i < nfds; i++) {
-   if (ufds[i].fd >= FD_SETSIZE) {
-   /* unsafe to set */
-   ufds[i].revents = POLLNVAL;
-   continue;
-   }
if (ufds[i].events & PHP_POLLREADABLE) {
-   FD_SET(ufds[i].fd, &rset);
+   PHP_SAFE_FD_SET(ufds[i].fd, &rset);
}
if (ufds[i].events & POLLOUT) {
-   FD_SET(ufds[i].fd, &wset);
+   PHP_SAFE_FD_SET(ufds[i].fd, &wset);
}
if (ufds[i].events & POLLPRI) {
-   FD_SET(ufds[i].fd, &eset);
+   PHP_SAFE_FD_SET(ufds[i].fd, &eset);
}
}
 
@@ -1081,30 +1076,24 @@
tv.tv_sec = timeout / 1000;
tv.tv_usec = (timeout - (tv.tv_sec * 1000)) * 1000;
}
-
n = select(max_fd + 1, &rset, &wset, &eset, timeout >= 0 ? &tv : NULL);
 
if (n >= 0) {
for (i = 0; i < nfds; i++) {
-   if (ufds[i].fd >= FD_SETSIZE) {
-   continue;
-   }
-
ufds[i].revents = 0;
 
-   if (FD_ISSET(ufds[i].fd, &rset)) {
+   if (PHP_SAFE_FD_ISSET(ufds[i].fd, &rset)) {
/* could be POLLERR or POLLHUP but can't tell without 
probing */
ufds[i].revents |= POLLIN;
}
-   if (FD_ISSET(ufds[i].fd, &wset)) {
+   if (PHP_SAFE_FD_ISSET(ufds[i].fd, &wset)) {
ufds[i].revents |= POLLOUT;
}
-   if (FD_ISSET(ufds[i].fd, &eset)) {
+   if (PHP_SAFE_FD_ISSET(ufds[i].fd, &eset)) {
ufds[i].revents |= POLLPRI;
}
}
}
-
return n;
 }
 
http://cvs.php.net/diff.php/php-src/main/streams/xp_socket.c?r1=1.29&r2=1.30&ty=u
Index: php-src/main/streams/xp_socket.c
diff -u php-src/main/streams/xp_socket.c:1.29 php-src/main/streams/xp_socket.c:1.30
--- php-src/main/streams/xp_socket.c:1.29   Fri Sep 17 08:44:56 2004
+++ php-src/main/streams/xp_socket.cFri Sep 17 10:36:55 2004
@@ -16,7 +16,7 @@
   +--+
 */
 
-/* $Id: xp_socket.c,v 1.29 2004/09/17 12:44:56 wez Exp $ */
+/* $Id: xp_socket.c,v 1.30 2004/09/17 14:36:55 wez Exp $ */
 
 #include "php.h"
 #include "ext/standard/file.h"
@@ -126,6 +126,9 @@
sock->timeout_event = 1;
 
if (retval >= 0)
+   break;
+
+   if (php_socket_errno() != EINTR)
break;
}
 }
http://cvs.php.net/diff.php/php-src/win32/build/config.w32?r1=1.31&r2=1.32&ty=u
Index: php-src/win32/build/config.w32
diff -u php-src/win32/build/config.w32:1.31 php-src/win32/build/config.w32:1.32
--- php-src/win32/build/config.w32:1.31 Fri Sep 17 08:44:56 2004
+++ php-src/win32/build/config.w32  Fri Sep 17 10:36:55 2004
@@ -1,5 +1,5 @@
 // vim:ft=javascript
-// $Id: config.w32,v 1.31 2004/09/17 12:44:56 wez Exp $
+// $Id: config.w32,v 1.32 2004/09/17 14:36:55 wez Exp $
 // "Master" config file; think of it as a configure.in
 // equivalent.
 
@@ -218,7 +218,7 @@
 /* this allows up to 256 sockets to be select()ed in a single
  * call to select(), instead of the usual 64 */
 ARG_ENABLE('fd-setsize', "Set maximum number of sockets for select(2)", "256");
-AC_DEFINE('FD_SETSIZE', PHP_FD_SETSIZE);
+ADD_FLAG("CFLAGS", "/D FD_SETSIZE=" + parseInt(PHP_FD_SETSIZE));
 
 ARG_ENABLE("memory-limit", "Enable memory limit checking code", "no");
 

-- 
PHP CVS Maili

[PHP-CVS] cvs: php-src /main network.c

2004-07-28 Thread Wez Furlong
wez Wed Jul 28 19:30:23 2004 EDT

  Modified files:  
/php-src/main   network.c 
  Log:
  Ensure that port numbers get set in the peer/socket name functions.
  (duh!)
  
  
http://cvs.php.net/diff.php/php-src/main/network.c?r1=1.110&r2=1.111&ty=u
Index: php-src/main/network.c
diff -u php-src/main/network.c:1.110 php-src/main/network.c:1.111
--- php-src/main/network.c:1.110Wed Jul 28 19:15:25 2004
+++ php-src/main/network.c  Wed Jul 28 19:30:23 2004
@@ -17,7 +17,7 @@
+--+
  */
 
-/* $Id: network.c,v 1.110 2004/07/28 23:15:25 wez Exp $ */
+/* $Id: network.c,v 1.111 2004/07/28 23:30:23 wez Exp $ */
 
 /*#define DEBUG_MAIN_NETWORK 1*/
 
@@ -501,7 +501,7 @@
addr++;
} else {
colon = memchr(addr, ':', addrlen);
-   if (!colon || colon[1] != ':') {
+   if (!colon) {
return FAILURE;
}
port = atoi(colon + 1);
@@ -592,8 +592,8 @@
/* generally not thread safe, but it *is* thread safe 
under win32 */
buf = inet_ntoa(((struct sockaddr_in*)sa)->sin_addr);
if (buf) {
-   *textaddrlen = strlen(buf);
-   *textaddr = estrndup(buf, *textaddrlen);
+   *textaddrlen = spprintf(textaddr, 0, "%s:%d", 
+   buf, ntohs(((struct 
sockaddr_in*)sa)->sin_port));
}
 
break;
@@ -602,8 +602,8 @@
case AF_INET6:
buf = (char*)inet_ntop(sa->sa_family, &((struct 
sockaddr_in6*)sa)->sin6_addr, (char *)&abuf, sizeof(abuf));
if (buf) {
-   *textaddrlen = strlen(buf);
-   *textaddr = estrndup(buf, *textaddrlen);
+   *textaddrlen = spprintf(textaddr, 0, "%s:%d", 
+   buf, ntohs(((struct 
sockaddr_in6*)sa)->sin6_port));
}
 
break;

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src /main network.c

2004-07-28 Thread Wez Furlong
wez Wed Jul 28 19:15:25 2004 EDT

  Modified files:  
/php-src/main   network.c 
  Log:
  Fix #29431: crash when parsing an invalid network address
  
  
http://cvs.php.net/diff.php/php-src/main/network.c?r1=1.109&r2=1.110&ty=u
Index: php-src/main/network.c
diff -u php-src/main/network.c:1.109 php-src/main/network.c:1.110
--- php-src/main/network.c:1.109Fri Apr  9 15:18:59 2004
+++ php-src/main/network.c  Wed Jul 28 19:15:25 2004
@@ -17,7 +17,7 @@
+--+
  */
 
-/* $Id: network.c,v 1.109 2004/04/09 19:18:59 pollita Exp $ */
+/* $Id: network.c,v 1.110 2004/07/28 23:15:25 wez Exp $ */
 
 /*#define DEBUG_MAIN_NETWORK 1*/
 
@@ -495,12 +495,15 @@
if (*addr == '[') {
colon = memchr(addr + 1, ']', addrlen-1);
if (!colon || colon[1] != ':') {
-   return 0;
+   return FAILURE;
}
port = atoi(colon + 2);
addr++;
} else {
colon = memchr(addr, ':', addrlen);
+   if (!colon || colon[1] != ':') {
+   return FAILURE;
+   }
port = atoi(colon + 1);
}
 

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src /main network.c

2004-04-09 Thread Sara Golemon
pollita Fri Apr  9 15:19:00 2004 EDT

  Modified files:  
/php-src/main   network.c 
  Log:
  BugFix: Copy/Paste mistake referenced undefined variable on platforms without 
gettimeofday()
  
http://cvs.php.net/diff.php/php-src/main/network.c?r1=1.108&r2=1.109&ty=u
Index: php-src/main/network.c
diff -u php-src/main/network.c:1.108 php-src/main/network.c:1.109
--- php-src/main/network.c:1.108Thu Jan  8 03:17:53 2004
+++ php-src/main/network.c  Fri Apr  9 15:18:59 2004
@@ -17,7 +17,7 @@
+--+
  */
 
-/* $Id: network.c,v 1.108 2004/01/08 08:17:53 andi Exp $ */
+/* $Id: network.c,v 1.109 2004/04/09 19:18:59 pollita Exp $ */
 
 /*#define DEBUG_MAIN_NETWORK 1*/
 
@@ -826,7 +826,7 @@
}
}
 #else
-   if (err == PHP_TIMEOUT_ERROR_VALUE) {
+   if (error_code && *error_code == PHP_TIMEOUT_ERROR_VALUE) {
/* Don't even bother trying to connect to the next 
alternative;
 * we have no way to determine how long we have 
already taken
 * and it is quite likely that the next attempt will 
fail too. */

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src /main network.c php_network.h

2003-12-02 Thread Wez Furlong
wez Tue Dec  2 18:13:44 2003 EDT

  Modified files:  
/php-src/main   network.c php_network.h 
  Log:
  Export these so that ftp extension can be build as shared ext.
  
  
Index: php-src/main/network.c
diff -u php-src/main/network.c:1.105 php-src/main/network.c:1.106
--- php-src/main/network.c:1.105Sun Nov 30 14:43:28 2003
+++ php-src/main/network.c  Tue Dec  2 18:13:43 2003
@@ -17,7 +17,7 @@
+--+
  */
 
-/* $Id: network.c,v 1.105 2003/11/30 19:43:28 iliaa Exp $ */
+/* $Id: network.c,v 1.106 2003/12/02 23:13:43 wez Exp $ */
 
 /*#define DEBUG_MAIN_NETWORK 1*/
 
@@ -856,7 +856,7 @@
 /* {{{ php_any_addr
  * Fills the any (wildcard) address into php_sockaddr_storage
  */
-void php_any_addr(int family, php_sockaddr_storage *addr, unsigned short port)
+PHPAPI void php_any_addr(int family, php_sockaddr_storage *addr, unsigned short port)
 {
memset(addr, 0, sizeof(php_sockaddr_storage));
switch (family) {
@@ -883,7 +883,7 @@
 /* {{{ php_sockaddr_size
  * Returns the size of struct sockaddr_xx for the family
  */
-int php_sockaddr_size(php_sockaddr_storage *addr)
+PHPAPI int php_sockaddr_size(php_sockaddr_storage *addr)
 {
switch (((struct sockaddr *)addr)->sa_family) {
case AF_INET:
Index: php-src/main/php_network.h
diff -u php-src/main/php_network.h:1.46 php-src/main/php_network.h:1.47
--- php-src/main/php_network.h:1.46 Sat Nov 29 16:46:49 2003
+++ php-src/main/php_network.h  Tue Dec  2 18:13:43 2003
@@ -16,7 +16,7 @@
+--+
  */
 
-/* $Id: php_network.h,v 1.46 2003/11/29 21:46:49 wez Exp $ */
+/* $Id: php_network.h,v 1.47 2003/12/02 23:13:43 wez Exp $ */
 
 #ifndef _PHP_NETWORK_H
 #define _PHP_NETWORK_H
@@ -153,8 +153,8 @@
socklen_t *addrlen
TSRMLS_DC);
 
-void php_any_addr(int family, php_sockaddr_storage *addr, unsigned short port);
-int php_sockaddr_size(php_sockaddr_storage *addr);
+PHPAPI void php_any_addr(int family, php_sockaddr_storage *addr, unsigned short port);
+PHPAPI int php_sockaddr_size(php_sockaddr_storage *addr);
 
 
 struct _php_netstream_data_t   {

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src /main network.c /main/streams xp_socket.c

2003-11-30 Thread Ilia Alshanetsky
iliaa   Sun Nov 30 14:43:30 2003 EDT

  Modified files:  
/php-src/main   network.c 
/php-src/main/streams   xp_socket.c 
  Log:
  Removed unused variables.
  
  
Index: php-src/main/network.c
diff -u php-src/main/network.c:1.104 php-src/main/network.c:1.105
--- php-src/main/network.c:1.104Sat Nov 29 16:46:49 2003
+++ php-src/main/network.c  Sun Nov 30 14:43:28 2003
@@ -17,7 +17,7 @@
+--+
  */
 
-/* $Id: network.c,v 1.104 2003/11/29 21:46:49 wez Exp $ */
+/* $Id: network.c,v 1.105 2003/11/30 19:43:28 iliaa Exp $ */
 
 /*#define DEBUG_MAIN_NETWORK 1*/
 
@@ -481,17 +481,14 @@
 PHPAPI int php_network_parse_network_address_with_port(const char *addr, long 
addrlen, struct sockaddr *sa, socklen_t *sl TSRMLS_DC)
 {
char *colon;
-   char *host = NULL;
-   int is_v6;
char *tmp;
int ret = FAILURE;
short port;
struct sockaddr_in *in4 = (struct sockaddr_in*)sa;
-   struct sockaddr **sal, **psal;
+   struct sockaddr **psal;
int n;
char *errstr = NULL;
 #ifdef HAVE_IPV6
-   char *p;
struct sockaddr_in6 *in6 = (struct sockaddr_in6*)sa;
 #endif
 
Index: php-src/main/streams/xp_socket.c
diff -u php-src/main/streams/xp_socket.c:1.18 php-src/main/streams/xp_socket.c:1.19
--- php-src/main/streams/xp_socket.c:1.18   Sat Nov 29 16:46:50 2003
+++ php-src/main/streams/xp_socket.cSun Nov 30 14:43:30 2003
@@ -16,7 +16,7 @@
   +--+
 */
 
-/* $Id: xp_socket.c,v 1.18 2003/11/29 21:46:50 wez Exp $ */
+/* $Id: xp_socket.c,v 1.19 2003/11/30 19:43:30 iliaa Exp $ */
 
 #include "php.h"
 #include "ext/standard/file.h"
@@ -141,9 +141,11 @@
 static int php_sockop_close(php_stream *stream, int close_handle TSRMLS_DC)
 {
php_netstream_data_t *sock = (php_netstream_data_t*)stream->abstract;
+#ifdef PHP_WIN32
fd_set wrfds, efds;
int n;
struct timeval timeout;
+#endif
 
if (close_handle) {
 

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src /main network.c /win32 select.c

2003-08-14 Thread Ilia Alshanetsky
iliaa   Mon Aug 11 20:58:53 2003 EDT

  Modified files:  
/php-src/main   network.c 
/php-src/win32  select.c 
  Log:
  emalloc -> safe_emalloc
  
  
Index: php-src/main/network.c
diff -u php-src/main/network.c:1.102 php-src/main/network.c:1.103
--- php-src/main/network.c:1.102Sun Aug 10 17:30:36 2003
+++ php-src/main/network.c  Mon Aug 11 20:58:52 2003
@@ -17,7 +17,7 @@
+--+
  */
 
-/* $Id: network.c,v 1.102 2003/08/10 21:30:36 helly Exp $ */
+/* $Id: network.c,v 1.103 2003/08/12 00:58:52 iliaa Exp $ */
 
 /*#define DEBUG_MAIN_NETWORK 1*/
 
@@ -240,7 +240,7 @@
in = *((struct in_addr *) host_info->h_addr);
}
 
-   *sal = emalloc(2 * sizeof(*sal));
+   *sal = safe_emalloc(2, sizeof(*sal), 0);
sap = *sal;
*sap = emalloc(sizeof(struct sockaddr_in));
(*sap)->sa_family = AF_INET;
Index: php-src/win32/select.c
diff -u php-src/win32/select.c:1.4 php-src/win32/select.c:1.5
--- php-src/win32/select.c:1.4  Tue Jun 10 16:03:46 2003
+++ php-src/win32/select.c  Mon Aug 11 20:58:52 2003
@@ -19,7 +19,7 @@
 #include "php.h"
 #include "php_network.h"
 
-/* $Id: select.c,v 1.4 2003/06/10 20:03:46 imajes Exp $ */
+/* $Id: select.c,v 1.5 2003/08/12 00:58:52 iliaa Exp $ */
 
 /* Win32 select() will only work with sockets, so we roll our own implementation that 
will
  * get the OS file handle from regular fd's and sockets and then use 
WaitForMultipleObjects().
@@ -50,7 +50,7 @@
return 0;
}
 
-   handles = (HANDLE*)emalloc((fd_count + sock_count) * sizeof(HANDLE));
+   handles = (HANDLE*)safe_emalloc((fd_count + sock_count), sizeof(HANDLE), 0);
 
/* populate the events and handles arrays */
f = 0;



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src /main network.c

2003-08-10 Thread Marcus Boerger
helly   Sun Aug 10 17:30:36 2003 EDT

  Modified files:  
/php-src/main   network.c 
  Log:
  Initialize this variable to 0 as suggested by sara
  
Index: php-src/main/network.c
diff -u php-src/main/network.c:1.101 php-src/main/network.c:1.102
--- php-src/main/network.c:1.101Sat Jun 28 07:12:48 2003
+++ php-src/main/network.c  Sun Aug 10 17:30:36 2003
@@ -17,7 +17,7 @@
+--+
  */
 
-/* $Id: network.c,v 1.101 2003/06/28 11:12:48 wez Exp $ */
+/* $Id: network.c,v 1.102 2003/08/10 21:30:36 helly Exp $ */
 
 /*#define DEBUG_MAIN_NETWORK 1*/
 
@@ -606,7 +606,7 @@
 {
php_socket_t clisock = -1;
fd_set rset;
-   int error, n;
+   int error = 0, n;
php_sockaddr_storage sa;
socklen_t sl;
 



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src /main network.c

2003-06-28 Thread Wez Furlong
wez Sat Jun 28 07:12:48 2003 EDT

  Modified files:  
/php-src/main   network.c 
  Log:
  Merge getaddrinfo() tidy-up from PHP_4_3 branch.
  
  
Index: php-src/main/network.c
diff -u php-src/main/network.c:1.100 php-src/main/network.c:1.101
--- php-src/main/network.c:1.100Tue Jun 10 16:03:41 2003
+++ php-src/main/network.c  Sat Jun 28 07:12:48 2003
@@ -17,7 +17,7 @@
+--+
  */
 
-/* $Id: network.c,v 1.100 2003/06/10 20:03:41 imajes Exp $ */
+/* $Id: network.c,v 1.101 2003/06/28 11:12:48 wez Exp $ */
 
 /*#define DEBUG_MAIN_NETWORK 1*/
 
@@ -164,11 +164,12 @@
 /* {{{ php_network_getaddresses
  * Returns number of addresses, 0 for none/error
  */
-static int php_network_getaddresses(const char *host, struct sockaddr ***sal, char 
**error_string TSRMLS_DC)
+static int php_network_getaddresses(const char *host, int socktype, struct sockaddr 
***sal, char **error_string TSRMLS_DC)
 {
struct sockaddr **sap;
int n;
 #ifdef HAVE_GETADDRINFO
+   static int ipv6_borked = -1; /* the way this is used *is* thread safe */
struct addrinfo hints, *res, *sai;
 #else
struct hostent *host_info;
@@ -178,59 +179,59 @@
if (host == NULL) {
return 0;
}
-
 #ifdef HAVE_GETADDRINFO
memset(&hints, '\0', sizeof(hints));
-
+   
+   hints.ai_family = AF_INET; /* default to regular inet (see below) */
+   hints.ai_socktype = socktype;
+   
 # ifdef HAVE_IPV6
-   hints.ai_family = AF_UNSPEC;
-# else
-   hints.ai_family = AF_INET;
-# endif
-   
-   if ((n = getaddrinfo(host, NULL, &hints, &res)) || res == NULL) {
-   if (error_string) {
-   spprintf(error_string, 0, "getaddrinfo: %s", (res == NULL ? 
"null result pointer" : PHP_GAI_STRERROR(n)));
+   /* probe for a working IPv6 stack; even if detected as having v6 at compile
+* time, at runtime some stacks are slow to resolve or have other issues
+* if they are not correctly configured.
+* static variable use is safe here since simple store or fetch operations
+* are atomic and because the actual probe process is not in danger of
+* collisions or race conditions. */
+   if (ipv6_borked == -1) {
+   int s;
+
+   s = socket(PF_INET6, SOCK_DGRAM, 0);
+   if (s == SOCK_ERR) {
+   ipv6_borked = 1;
} else {
-   php_error_docref(NULL TSRMLS_CC, E_WARNING, 
"php_network_getaddresses: getaddrinfo failed: %s", (res == NULL ? "null result 
pointer" : PHP_GAI_STRERROR(n)));
+   ipv6_borked = 0;
+   closesocket(s);
}
+   }
+   hints.ai_family = ipv6_borked ? AF_INET : AF_UNSPEC;
+# endif
+   
+   if ((n = getaddrinfo(host, NULL, &hints, &res))) {
+   php_error_docref(NULL TSRMLS_CC, E_WARNING, "php_network_getaddresses: 
getaddrinfo failed: %s", PHP_GAI_STRERROR(n));
+   return 0;
+   } else if (res == NULL) {
+   php_error_docref(NULL TSRMLS_CC, E_WARNING, "php_network_getaddresses: 
getaddrinfo failed (null result pointer)");
return 0;
}
 
sai = res;
-
-   for (n = 1; (sai = sai->ai_next) != NULL; n++) {
+   for (n = 1; (sai = sai->ai_next) != NULL; n++)
;
-   }
-   
+   
*sal = safe_emalloc((n + 1), sizeof(*sal), 0);
sai = res;
sap = *sal;
+   
do {
-   switch (sai->ai_family) {
-# if HAVE_IPV6
-   case AF_INET6:
-   *sap = emalloc(sizeof(struct sockaddr_in6));
-   *(struct sockaddr_in6 *)*sap =
-   *((struct sockaddr_in6 *)sai->ai_addr);
-   sap++;
-   break;
-# endif
-   case AF_INET:
-   *sap = emalloc(sizeof(struct sockaddr_in));
-   *(struct sockaddr_in *)*sap =
-   *((struct sockaddr_in *)sai->ai_addr);
-   sap++;
-   break;
-   }
+   *sap = emalloc(sai->ai_addrlen);
+   memcpy(*sap, sai->ai_addr, sai->ai_addrlen);
+   sap++;
} while ((sai = sai->ai_next) != NULL);
+   
freeaddrinfo(res);
 #else
-
if (!inet_aton(host, &in)) {
-   /* XXX NOT THREAD SAFE
-* (but it *is* thread safe under win32)
-*/
+   /* XXX NOT THREAD SAFE (is safe under win32) */
host_info = gethostbyname(host);
if (host_info == NULL) {
php_error_docref(NULL TSRMLS_CC,