[PHP-CVS] cvs: php-src /sapi/cgi fastcgi.c
pajoye Thu Dec 11 10:20:30 2008 UTC Modified files: /php-src/sapi/cgi fastcgi.c Log: - WS http://cvs.php.net/viewvc.cgi/php-src/sapi/cgi/fastcgi.c?r1=1.51&r2=1.52&diff_format=u Index: php-src/sapi/cgi/fastcgi.c diff -u php-src/sapi/cgi/fastcgi.c:1.51 php-src/sapi/cgi/fastcgi.c:1.52 --- php-src/sapi/cgi/fastcgi.c:1.51 Thu Dec 11 00:15:05 2008 +++ php-src/sapi/cgi/fastcgi.c Thu Dec 11 10:20:30 2008 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: fastcgi.c,v 1.51 2008/12/11 00:15:05 pajoye Exp $ */ +/* $Id: fastcgi.c,v 1.52 2008/12/11 10:20:30 pajoye Exp $ */ #include "php.h" #include "fastcgi.h" @@ -267,63 +267,63 @@ */ static PACL prepare_named_pipe_acl(PSECURITY_DESCRIPTOR sd, LPSECURITY_ATTRIBUTES sa) { - DWORD req_acl_size; - char everyone_buf[32], owner_buf[32]; - PSID sid_everyone, sid_owner; - SID_IDENTIFIER_AUTHORITY -siaWorld = SECURITY_WORLD_SID_AUTHORITY, -siaCreator = SECURITY_CREATOR_SID_AUTHORITY; - PACL acl; - - sid_everyone = (PSID)&everyone_buf; - sid_owner = (PSID)&owner_buf; - - req_acl_size = sizeof(ACL) + -(2 * ((sizeof(ACCESS_ALLOWED_ACE) - sizeof(DWORD)) + GetSidLengthRequired(1))); - - acl = malloc(req_acl_size); - - if (acl == NULL) { -return NULL; - } - - if (!InitializeSid(sid_everyone, &siaWorld, 1)) { -goto out_fail; - } - *GetSidSubAuthority(sid_everyone, 0) = SECURITY_WORLD_RID; - - if (!InitializeSid(sid_owner, &siaCreator, 1)) { -goto out_fail; - } - *GetSidSubAuthority(sid_owner, 0) = SECURITY_CREATOR_OWNER_RID; - - if (!InitializeAcl(acl, req_acl_size, ACL_REVISION)) { -goto out_fail; - } - - if (!AddAccessAllowedAce(acl, ACL_REVISION, FILE_GENERIC_READ | FILE_GENERIC_WRITE, sid_everyone)) { -goto out_fail; - } - - if (!AddAccessAllowedAce(acl, ACL_REVISION, FILE_ALL_ACCESS, sid_owner)) { -goto out_fail; - } - - if (!InitializeSecurityDescriptor(sd, SECURITY_DESCRIPTOR_REVISION)) { -goto out_fail; - } - - if (!SetSecurityDescriptorDacl(sd, TRUE, acl, FALSE)) { -goto out_fail; - } + DWORD req_acl_size; + char everyone_buf[32], owner_buf[32]; + PSID sid_everyone, sid_owner; + SID_IDENTIFIER_AUTHORITY + siaWorld = SECURITY_WORLD_SID_AUTHORITY, + siaCreator = SECURITY_CREATOR_SID_AUTHORITY; + PACL acl; - sa->lpSecurityDescriptor = sd; + sid_everyone = (PSID)&everyone_buf; + sid_owner = (PSID)&owner_buf; - return acl; + req_acl_size = sizeof(ACL) + + (2 * ((sizeof(ACCESS_ALLOWED_ACE) - sizeof(DWORD)) + GetSidLengthRequired(1))); + + acl = malloc(req_acl_size); + + if (acl == NULL) { + return NULL; + } + + if (!InitializeSid(sid_everyone, &siaWorld, 1)) { + goto out_fail; + } + *GetSidSubAuthority(sid_everyone, 0) = SECURITY_WORLD_RID; + + if (!InitializeSid(sid_owner, &siaCreator, 1)) { + goto out_fail; + } + *GetSidSubAuthority(sid_owner, 0) = SECURITY_CREATOR_OWNER_RID; + + if (!InitializeAcl(acl, req_acl_size, ACL_REVISION)) { + goto out_fail; + } + + if (!AddAccessAllowedAce(acl, ACL_REVISION, FILE_GENERIC_READ | FILE_GENERIC_WRITE, sid_everyone)) { + goto out_fail; + } + + if (!AddAccessAllowedAce(acl, ACL_REVISION, FILE_ALL_ACCESS, sid_owner)) { + goto out_fail; + } + + if (!InitializeSecurityDescriptor(sd, SECURITY_DESCRIPTOR_REVISION)) { + goto out_fail; + } + + if (!SetSecurityDescriptorDacl(sd, TRUE, acl, FALSE)) { + goto out_fail; + } + + sa->lpSecurityDescriptor = sd; + + return acl; out_fail: - free(acl); - return NULL; + free(acl); + return NULL; } #endif @@ -960,13 +960,13 @@ int n = 0; int allowed = 0; - while (allowed_clients[n] != INADDR_NONE) { - if (allowed_clients[n] == sa.sa_inet.sin_addr.s_addr) { - allowed = 1; - break; - } - n++; - } + while (allowed_clients[n] != INADDR_NONE) { + if (allowed_clients[n] == sa.sa_inet.sin_addr.s_addr) { + allowed = 1; + break; + } +
[PHP-CVS] cvs: php-src /sapi/cgi fastcgi.c
pajoye Thu Dec 11 00:15:05 2008 UTC Modified files: /php-src/sapi/cgi fastcgi.c Log: - ws http://cvs.php.net/viewvc.cgi/php-src/sapi/cgi/fastcgi.c?r1=1.50&r2=1.51&diff_format=u Index: php-src/sapi/cgi/fastcgi.c diff -u php-src/sapi/cgi/fastcgi.c:1.50 php-src/sapi/cgi/fastcgi.c:1.51 --- php-src/sapi/cgi/fastcgi.c:1.50 Sun Dec 7 10:54:16 2008 +++ php-src/sapi/cgi/fastcgi.c Thu Dec 11 00:15:05 2008 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: fastcgi.c,v 1.50 2008/12/07 10:54:16 mattwil Exp $ */ +/* $Id: fastcgi.c,v 1.51 2008/12/11 00:15:05 pajoye Exp $ */ #include "php.h" #include "fastcgi.h" @@ -456,35 +456,35 @@ if (!tcp) { chmod(path, 0777); } else { - char *ip = getenv("FCGI_WEB_SERVER_ADDRS"); - char *cur, *end; - int n; - - if (ip) { - ip = strdup(ip); - cur = ip; - n = 0; - while (*cur) { - if (*cur == ',') n++; - cur++; - } - allowed_clients = malloc(sizeof(in_addr_t) * (n+2)); - n = 0; - cur = ip; - while (cur) { - end = strchr(cur, ','); - if (end) { - *end = 0; - end++; - } - allowed_clients[n] = inet_addr(cur); - if (allowed_clients[n] == INADDR_NONE) { + char *ip = getenv("FCGI_WEB_SERVER_ADDRS"); + char *cur, *end; + int n; + + if (ip) { + ip = strdup(ip); + cur = ip; + n = 0; + while (*cur) { + if (*cur == ',') n++; + cur++; + } + allowed_clients = malloc(sizeof(in_addr_t) * (n+2)); + n = 0; + cur = ip; + while (cur) { + end = strchr(cur, ','); + if (end) { + *end = 0; + end++; + } + allowed_clients[n] = inet_addr(cur); + if (allowed_clients[n] == INADDR_NONE) { fprintf(stderr, "Wrong IP address '%s' in FCGI_WEB_SERVER_ADDRS\n", cur); - } - n++; - cur = end; - } - allowed_clients[n] = INADDR_NONE; + } + n++; + cur = end; + } + allowed_clients[n] = INADDR_NONE; free(ip); } } -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /sapi/cgi fastcgi.c
mattwil Sun Dec 7 10:54:16 2008 UTC Modified files: /php-src/sapi/cgi fastcgi.c Log: Fixed bug #46782 (fastcgi.c parse error) http://cvs.php.net/viewvc.cgi/php-src/sapi/cgi/fastcgi.c?r1=1.49&r2=1.50&diff_format=u Index: php-src/sapi/cgi/fastcgi.c diff -u php-src/sapi/cgi/fastcgi.c:1.49 php-src/sapi/cgi/fastcgi.c:1.50 --- php-src/sapi/cgi/fastcgi.c:1.49 Tue Oct 21 03:19:07 2008 +++ php-src/sapi/cgi/fastcgi.c Sun Dec 7 10:54:16 2008 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: fastcgi.c,v 1.49 2008/10/21 03:19:07 lbarnaud Exp $ */ +/* $Id: fastcgi.c,v 1.50 2008/12/07 10:54:16 mattwil Exp $ */ #include "php.h" #include "fastcgi.h" @@ -191,8 +191,14 @@ int fcgi_init(void) { if (!is_initialized) { +#ifndef _WIN32 + sa_t sa; + socklen_t len = sizeof(sa); +#endif zend_hash_init(&fcgi_mgmt_vars, 0, NULL, fcgi_free_mgmt_var_cb, 1); fcgi_set_mgmt_var("FCGI_MPXS_CONNS", sizeof("FCGI_MPXS_CONNS")-1, "0", sizeof("0")-1); + + is_initialized = 1; #ifdef _WIN32 # if 0 /* TODO: Support for TCP sockets */ @@ -203,8 +209,6 @@ return 0; } # endif - is_initialized = 1; - if ((GetStdHandle(STD_OUTPUT_HANDLE) == INVALID_HANDLE_VALUE) && (GetStdHandle(STD_ERROR_HANDLE) == INVALID_HANDLE_VALUE) && (GetStdHandle(STD_INPUT_HANDLE) != INVALID_HANDLE_VALUE)) { @@ -231,10 +235,6 @@ return is_fastcgi = 0; } #else - sa_t sa; - socklen_t len = sizeof(sa); - - is_initialized = 1; errno = 0; if (getpeername(0, (struct sockaddr *)&sa, &len) != 0 && errno == ENOTCONN) { fcgi_setup_signals(); -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /sapi/cgi fastcgi.c
dmitry Thu Apr 3 10:25:08 2008 UTC Modified files: /php-src/sapi/cgi fastcgi.c Log: - Fixed possible stack buffer overflow in FastCGI SAPI. (Andrey Nigmatulin) - Fixed sending of uninitialized paddings which may contain some information. (Andrey Nigmatulin) http://cvs.php.net/viewvc.cgi/php-src/sapi/cgi/fastcgi.c?r1=1.44&r2=1.45&diff_format=u Index: php-src/sapi/cgi/fastcgi.c diff -u php-src/sapi/cgi/fastcgi.c:1.44 php-src/sapi/cgi/fastcgi.c:1.45 --- php-src/sapi/cgi/fastcgi.c:1.44 Fri Feb 15 14:51:52 2008 +++ php-src/sapi/cgi/fastcgi.c Thu Apr 3 10:25:08 2008 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: fastcgi.c,v 1.44 2008/02/15 14:51:52 dmitry Exp $ */ +/* $Id: fastcgi.c,v 1.45 2008/04/03 10:25:08 dmitry Exp $ */ #include "php.h" #include "fastcgi.h" @@ -593,6 +593,9 @@ hdr->reserved = 0; hdr->type = type; hdr->version = FCGI_VERSION_1; + if (pad) { + memset(((unsigned char*)hdr) + sizeof(fcgi_header) + len, 0, pad); + } return pad; } @@ -777,7 +780,7 @@ { int ret, n, rest; fcgi_header hdr; - unsigned char buf[8]; + unsigned char buf[255]; n = 0; rest = len; -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /sapi/cgi fastcgi.c
dmitry Fri Sep 7 08:42:33 2007 UTC Modified files: /php-src/sapi/cgi fastcgi.c Log: forgotten part http://cvs.php.net/viewvc.cgi/php-src/sapi/cgi/fastcgi.c?r1=1.41&r2=1.42&diff_format=u Index: php-src/sapi/cgi/fastcgi.c diff -u php-src/sapi/cgi/fastcgi.c:1.41 php-src/sapi/cgi/fastcgi.c:1.42 --- php-src/sapi/cgi/fastcgi.c:1.41 Fri Sep 7 08:30:10 2007 +++ php-src/sapi/cgi/fastcgi.c Fri Sep 7 08:42:33 2007 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: fastcgi.c,v 1.41 2007/09/07 08:30:10 dmitry Exp $ */ +/* $Id: fastcgi.c,v 1.42 2007/09/07 08:42:33 dmitry Exp $ */ #include "php.h" #include "fastcgi.h" @@ -717,6 +717,10 @@ padding = hdr.paddingLength; while (hdr.type == FCGI_PARAMS && len > 0) { + if (len + padding > FCGI_MAX_LENGTH) { + return 0; + } + if (safe_read(req, buf, len+padding) != len+padding) { req->keep = 0; return 0; -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /sapi/cgi fastcgi.c
dmitry Fri Sep 7 08:30:11 2007 UTC Modified files: /php-src/sapi/cgi fastcgi.c Log: Added checks for malformated FastCGI requests (Mattias Bengtsson) http://cvs.php.net/viewvc.cgi/php-src/sapi/cgi/fastcgi.c?r1=1.40&r2=1.41&diff_format=u Index: php-src/sapi/cgi/fastcgi.c diff -u php-src/sapi/cgi/fastcgi.c:1.40 php-src/sapi/cgi/fastcgi.c:1.41 --- php-src/sapi/cgi/fastcgi.c:1.40 Mon Jul 9 11:48:53 2007 +++ php-src/sapi/cgi/fastcgi.c Fri Sep 7 08:30:10 2007 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: fastcgi.c,v 1.40 2007/07/09 11:48:53 dmitry Exp $ */ +/* $Id: fastcgi.c,v 1.41 2007/09/07 08:30:10 dmitry Exp $ */ #include "php.h" #include "fastcgi.h" @@ -620,7 +620,8 @@ val_len |= (*p++ << 8); val_len |= *p++; } - if (p + name_len + val_len > end) { + if (name_len + val_len < 0 || + name_len + val_len > end - p) { /* Malformated request */ ret = 0; break; @@ -676,6 +677,10 @@ padding = hdr.paddingLength; } + if (len + padding > FCGI_MAX_LENGTH) { + return 0; + } + req->id = (hdr.requestIdB1 << 8) + hdr.requestIdB0; if (hdr.type == FCGI_BEGIN_REQUEST && len == sizeof(fcgi_begin_request)) { -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /sapi/cgi fastcgi.c
dmitry Mon Jul 9 11:48:53 2007 UTC Modified files: /php-src/sapi/cgi fastcgi.c Log: ECONNABORTED is not a critical error (Andrei Nigmatulin) http://cvs.php.net/viewvc.cgi/php-src/sapi/cgi/fastcgi.c?r1=1.39&r2=1.40&diff_format=u Index: php-src/sapi/cgi/fastcgi.c diff -u php-src/sapi/cgi/fastcgi.c:1.39 php-src/sapi/cgi/fastcgi.c:1.40 --- php-src/sapi/cgi/fastcgi.c:1.39 Mon May 21 09:08:25 2007 +++ php-src/sapi/cgi/fastcgi.c Mon Jul 9 11:48:53 2007 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: fastcgi.c,v 1.39 2007/05/21 09:08:25 dmitry Exp $ */ +/* $Id: fastcgi.c,v 1.40 2007/07/09 11:48:53 dmitry Exp $ */ #include "php.h" #include "fastcgi.h" @@ -927,7 +927,11 @@ } } +#ifdef _WIN32 if (req->fd < 0 && (in_shutdown || errno != EINTR)) { +#else + if (req->fd < 0 && (in_shutdown || (errno != EINTR && errno != ECONNABORTED))) { +#endif return -1; } -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /sapi/cgi fastcgi.c
dmitry Thu May 10 15:22:15 2007 UTC Modified files: /php-src/sapi/cgi fastcgi.c Log: Fixed bug #41291 (FastCGI does not set SO_REUSEADDR). (fmajid at kefta dot com) http://cvs.php.net/viewvc.cgi/php-src/sapi/cgi/fastcgi.c?r1=1.37&r2=1.38&diff_format=u Index: php-src/sapi/cgi/fastcgi.c diff -u php-src/sapi/cgi/fastcgi.c:1.37 php-src/sapi/cgi/fastcgi.c:1.38 --- php-src/sapi/cgi/fastcgi.c:1.37 Mon Apr 9 15:40:23 2007 +++ php-src/sapi/cgi/fastcgi.c Thu May 10 15:22:15 2007 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: fastcgi.c,v 1.37 2007/04/09 15:40:23 dmitry Exp $ */ +/* $Id: fastcgi.c,v 1.38 2007/05/10 15:22:15 dmitry Exp $ */ #include "php.h" #include "fastcgi.h" @@ -345,6 +345,13 @@ int listen_socket; sa_t sa; socklen_t sock_len; +#ifdef SO_REUSEADDR +# ifdef _WIN32 + BOOL reuse = 1; +# else + int reuse = 1; +# endif +#endif if ((s = strchr(path, ':'))) { port = atoi(s+1); @@ -434,6 +441,9 @@ /* Create, bind socket and start listen on it */ if ((listen_socket = socket(sa.sa.sa_family, SOCK_STREAM, 0)) < 0 || +#ifdef SO_REUSEADDR + setsockopt(listen_socket, SOL_SOCKET, SO_REUSEADDR, (char*)&reuse, sizeof(reuse)) < 0 || +#endif bind(listen_socket, (struct sockaddr *) &sa, sock_len) < 0 || listen(listen_socket, backlog) < 0) { -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /sapi/cgi fastcgi.c
dmitry Mon Apr 9 15:40:23 2007 UTC Modified files: /php-src/sapi/cgi fastcgi.c Log: Removed wrong size_t definition http://cvs.php.net/viewvc.cgi/php-src/sapi/cgi/fastcgi.c?r1=1.36&r2=1.37&diff_format=u Index: php-src/sapi/cgi/fastcgi.c diff -u php-src/sapi/cgi/fastcgi.c:1.36 php-src/sapi/cgi/fastcgi.c:1.37 --- php-src/sapi/cgi/fastcgi.c:1.36 Wed Mar 28 15:39:35 2007 +++ php-src/sapi/cgi/fastcgi.c Mon Apr 9 15:40:23 2007 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: fastcgi.c,v 1.36 2007/03/28 15:39:35 dmitry Exp $ */ +/* $Id: fastcgi.c,v 1.37 2007/04/09 15:40:23 dmitry Exp $ */ #include "php.h" #include "fastcgi.h" @@ -31,7 +31,6 @@ #include - typedef unsigned int size_t; typedef unsigned int in_addr_t; struct sockaddr_un { -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /sapi/cgi fastcgi.c
dmitry Mon Mar 12 07:39:24 2007 UTC Modified files: /php-src/sapi/cgi fastcgi.c Log: Fixed compilation warning http://cvs.php.net/viewvc.cgi/php-src/sapi/cgi/fastcgi.c?r1=1.34&r2=1.35&diff_format=u Index: php-src/sapi/cgi/fastcgi.c diff -u php-src/sapi/cgi/fastcgi.c:1.34 php-src/sapi/cgi/fastcgi.c:1.35 --- php-src/sapi/cgi/fastcgi.c:1.34 Mon Feb 26 09:39:08 2007 +++ php-src/sapi/cgi/fastcgi.c Mon Mar 12 07:39:24 2007 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: fastcgi.c,v 1.34 2007/02/26 09:39:08 dmitry Exp $ */ +/* $Id: fastcgi.c,v 1.35 2007/03/12 07:39:24 dmitry Exp $ */ #include "php.h" #include "fastcgi.h" @@ -133,7 +133,7 @@ typedef struct _fcgi_mgmt_rec { char* name; - size_t name_len; + char name_len; char val; } fcgi_mgmt_rec; -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /sapi/cgi fastcgi.c
dmitry Mon Feb 26 09:39:08 2007 UTC Modified files: /php-src/sapi/cgi fastcgi.c Log: poll() is not affected by FD_SETSIZE (Tony) http://cvs.php.net/viewvc.cgi/php-src/sapi/cgi/fastcgi.c?r1=1.33&r2=1.34&diff_format=u Index: php-src/sapi/cgi/fastcgi.c diff -u php-src/sapi/cgi/fastcgi.c:1.33 php-src/sapi/cgi/fastcgi.c:1.34 --- php-src/sapi/cgi/fastcgi.c:1.33 Sat Feb 24 11:21:10 2007 +++ php-src/sapi/cgi/fastcgi.c Mon Feb 26 09:39:08 2007 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: fastcgi.c,v 1.33 2007/02/24 11:21:10 dmitry Exp $ */ +/* $Id: fastcgi.c,v 1.34 2007/02/26 09:39:08 dmitry Exp $ */ #include "php.h" #include "fastcgi.h" @@ -764,22 +764,23 @@ break; #else if (req->fd >= 0) { - if (req->fd < FD_SETSIZE) { #if defined(HAVE_SYS_POLL_H) && defined(HAVE_POLL) - struct pollfd fds; - int ret; + struct pollfd fds; + int ret; - fds.fd = req->fd; - fds.events = POLLIN; - fds.revents = 0; - do { - errno = 0; - ret = poll(&fds, 1, 5000); - } while (ret < 0 && errno == EINTR); - if (ret > 0 && (fds.revents & POLLIN)) { - break; - } + fds.fd = req->fd; + fds.events = POLLIN; + fds.revents = 0; + do { + errno = 0; + ret = poll(&fds, 1, 5000); + } while (ret < 0 && errno == EINTR); + if (ret > 0 && (fds.revents & POLLIN)) { + break; + } + fcgi_close(req, 1, 0); #else + if (req->fd < FD_SETSIZE) { struct timeval tv = {5,0}; fd_set set; int ret; @@ -793,12 +794,12 @@ if (ret > 0 && FD_ISSET(req->fd, &set)) { break; } -#endif fcgi_close(req, 1, 0); } else { fprintf(stderr, "Too many open file descriptors. FD_SETSIZE limit exceeded."); fcgi_close(req, 1, 0); } +#endif } #endif } -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /sapi/cgi fastcgi.c
dmitry Sat Feb 24 11:21:10 2007 UTC Modified files: /php-src/sapi/cgi fastcgi.c Log: Use poll() instead of select() if available http://cvs.php.net/viewvc.cgi/php-src/sapi/cgi/fastcgi.c?r1=1.32&r2=1.33&diff_format=u Index: php-src/sapi/cgi/fastcgi.c diff -u php-src/sapi/cgi/fastcgi.c:1.32 php-src/sapi/cgi/fastcgi.c:1.33 --- php-src/sapi/cgi/fastcgi.c:1.32 Wed Feb 21 15:46:30 2007 +++ php-src/sapi/cgi/fastcgi.c Sat Feb 24 11:21:10 2007 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: fastcgi.c,v 1.32 2007/02/21 15:46:30 dmitry Exp $ */ +/* $Id: fastcgi.c,v 1.33 2007/02/24 11:21:10 dmitry Exp $ */ #include "php.h" #include "fastcgi.h" @@ -71,6 +71,13 @@ # include # include +# if defined(HAVE_SYS_POLL_H) && defined(HAVE_POLL) +# include +# endif +# if defined(HAVE_SYS_SELECT_H) +# include +# endif + #ifndef INADDR_NONE #define INADDR_NONE ((unsigned long) -1) #endif @@ -758,17 +765,35 @@ #else if (req->fd >= 0) { if (req->fd < FD_SETSIZE) { +#if defined(HAVE_SYS_POLL_H) && defined(HAVE_POLL) + struct pollfd fds; + int ret; + + fds.fd = req->fd; + fds.events = POLLIN; + fds.revents = 0; + do { + errno = 0; + ret = poll(&fds, 1, 5000); + } while (ret < 0 && errno == EINTR); + if (ret > 0 && (fds.revents & POLLIN)) { + break; + } +#else struct timeval tv = {5,0}; fd_set set; + int ret; FD_ZERO(&set); FD_SET(req->fd, &set); -try_again: - errno = 0; - if (select(req->fd + 1, &set, NULL, NULL, &tv) >= 0 && FD_ISSET(req->fd, &set)) { + do { + errno = 0; + ret = select(req->fd + 1, &set, NULL, NULL, &tv) >= 0; + } while (ret < 0 && errno == EINTR); + if (ret > 0 && FD_ISSET(req->fd, &set)) { break; } - if (errno == EINTR) goto try_again; +#endif fcgi_close(req, 1, 0); } else { fprintf(stderr, "Too many open file descriptors. FD_SETSIZE limit exceeded."); -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /sapi/cgi fastcgi.c
dmitry Wed Feb 21 15:46:30 2007 UTC Modified files: /php-src/sapi/cgi fastcgi.c Log: Check for FD_SETSIZE limit http://cvs.php.net/viewvc.cgi/php-src/sapi/cgi/fastcgi.c?r1=1.31&r2=1.32&diff_format=u Index: php-src/sapi/cgi/fastcgi.c diff -u php-src/sapi/cgi/fastcgi.c:1.31 php-src/sapi/cgi/fastcgi.c:1.32 --- php-src/sapi/cgi/fastcgi.c:1.31 Mon Feb 19 13:21:49 2007 +++ php-src/sapi/cgi/fastcgi.c Wed Feb 21 15:46:30 2007 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: fastcgi.c,v 1.31 2007/02/19 13:21:49 dmitry Exp $ */ +/* $Id: fastcgi.c,v 1.32 2007/02/21 15:46:30 dmitry Exp $ */ #include "php.h" #include "fastcgi.h" @@ -757,18 +757,23 @@ break; #else if (req->fd >= 0) { - struct timeval tv = {5,0}; - fd_set set; + if (req->fd < FD_SETSIZE) { + struct timeval tv = {5,0}; + fd_set set; - FD_ZERO(&set); - FD_SET(req->fd, &set); + FD_ZERO(&set); + FD_SET(req->fd, &set); try_again: - errno = 0; - if (select(req->fd + 1, &set, NULL, NULL, &tv) >= 0 && FD_ISSET(req->fd, &set)) { - break; + errno = 0; + if (select(req->fd + 1, &set, NULL, NULL, &tv) >= 0 && FD_ISSET(req->fd, &set)) { + break; + } + if (errno == EINTR) goto try_again; + fcgi_close(req, 1, 0); + } else { + fprintf(stderr, "Too many open file descriptors. FD_SETSIZE limit exceeded."); + fcgi_close(req, 1, 0); } - if (errno == EINTR) goto try_again; - fcgi_close(req, 1, 0); } #endif } -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /sapi/cgi fastcgi.c
dmitry Mon Feb 19 13:21:49 2007 UTC Modified files: /php-src/sapi/cgi fastcgi.c Log: Fixed fcgi_putenv() semantic with NULL value http://cvs.php.net/viewvc.cgi/php-src/sapi/cgi/fastcgi.c?r1=1.30&r2=1.31&diff_format=u Index: php-src/sapi/cgi/fastcgi.c diff -u php-src/sapi/cgi/fastcgi.c:1.30 php-src/sapi/cgi/fastcgi.c:1.31 --- php-src/sapi/cgi/fastcgi.c:1.30 Thu Feb 15 12:33:54 2007 +++ php-src/sapi/cgi/fastcgi.c Mon Feb 19 13:21:49 2007 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: fastcgi.c,v 1.30 2007/02/15 12:33:54 dmitry Exp $ */ +/* $Id: fastcgi.c,v 1.31 2007/02/19 13:21:49 dmitry Exp $ */ #include "php.h" #include "fastcgi.h" @@ -975,14 +975,15 @@ char* fcgi_putenv(fcgi_request *req, char* var, int var_len, char* val) { if (var && req) { - char **ret; - if (val == NULL) { - val = ""; - } - val = strdup(val); - if (zend_hash_update(&req->env, var, var_len+1, &val, sizeof(char*), (void**)&ret) == SUCCESS) { - return *ret; + zend_hash_del(&req->env, var, var_len+1); + } else { + char **ret; + + val = strdup(val); + if (zend_hash_update(&req->env, var, var_len+1, &val, sizeof(char*), (void**)&ret) == SUCCESS) { + return *ret; + } } } return NULL; -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /sapi/cgi fastcgi.c
dmitry Thu Feb 15 12:05:25 2007 UTC Modified files: /php-src/sapi/cgi fastcgi.c Log: Fixed Bug #40352 (FCGI_WEB_SERVER_ADDRS function get lost) http://cvs.php.net/viewvc.cgi/php-src/sapi/cgi/fastcgi.c?r1=1.28&r2=1.29&diff_format=u Index: php-src/sapi/cgi/fastcgi.c diff -u php-src/sapi/cgi/fastcgi.c:1.28 php-src/sapi/cgi/fastcgi.c:1.29 --- php-src/sapi/cgi/fastcgi.c:1.28 Mon Jan 1 09:29:36 2007 +++ php-src/sapi/cgi/fastcgi.c Thu Feb 15 12:05:25 2007 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: fastcgi.c,v 1.28 2007/01/01 09:29:36 sebastian Exp $ */ +/* $Id: fastcgi.c,v 1.29 2007/02/15 12:05:25 dmitry Exp $ */ #include "php.h" #include "fastcgi.h" @@ -153,6 +153,8 @@ #else +static in_addr_t *allowed_clients = NULL; + static void fcgi_signal_handler(int signo) { if (signo == SIGUSR1 || signo == SIGTERM) { @@ -317,6 +319,38 @@ if (!tcp) { chmod(path, 0777); + } else { + char *ip = getenv("FCGI_WEB_SERVER_ADDRS"); + char *cur, *end; + int n; + + if (ip) { + ip = strdup(ip); + cur = ip; + n = 0; + while (*cur) { + if (*cur == ',') n++; + cur++; + } + allowed_clients = malloc(sizeof(in_addr_t) * (n+2)); + n = 0; + cur = ip; + while (cur) { + end = strchr(cur, ','); + if (end) { + *end = 0; + end++; + } + allowed_clients[n] = inet_addr(cur); + if (allowed_clients[n] == INADDR_NONE) { + fprintf(stderr, "Wrong IP address '%s' in FCGI_WEB_SERVER_ADDRS\n", cur); + } + n++; + cur = end; + } + allowed_clients[n] = INADDR_NONE; + free(ip); + } } if (!is_initialized) { @@ -689,6 +723,24 @@ FCGI_LOCK(req->listen_socket); req->fd = accept(req->listen_socket, (struct sockaddr *)&sa, &len); FCGI_UNLOCK(req->listen_socket); + if (req->fd >= 0 && allowed_clients) { + int n = 0; + int allowed = 0; + + while (allowed_clients[n] != INADDR_NONE) { + if (allowed_clients[n] == sa.sa_inet.sin_addr.s_addr) { + allowed = 1; + break; + } + n++; + } + if (!allowed) { + fprintf(stderr, "Connection from disallowed IP address '%s' is dropped.\n", inet_ntoa(sa.sa_inet.sin_addr)); + close(req->fd); + req->fd = -1; + continue; + } + } } #endif -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /sapi/cgi fastcgi.c
dmitry Tue Dec 19 09:17:28 2006 UTC Modified files: /php-src/sapi/cgi fastcgi.c Log: Fixed bug #39869 (safe_read does not initialize errno). (michiel at boland dot org) http://cvs.php.net/viewvc.cgi/php-src/sapi/cgi/fastcgi.c?r1=1.26&r2=1.27&diff_format=u Index: php-src/sapi/cgi/fastcgi.c diff -u php-src/sapi/cgi/fastcgi.c:1.26 php-src/sapi/cgi/fastcgi.c:1.27 --- php-src/sapi/cgi/fastcgi.c:1.26 Tue Dec 5 08:55:34 2006 +++ php-src/sapi/cgi/fastcgi.c Tue Dec 19 09:17:28 2006 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: fastcgi.c,v 1.26 2006/12/05 08:55:34 dmitry Exp $ */ +/* $Id: fastcgi.c,v 1.27 2006/12/19 09:17:28 dmitry Exp $ */ #include "php.h" #include "fastcgi.h" @@ -347,6 +347,7 @@ size_t n = 0; do { + errno = 0; ret = write(req->fd, ((char*)buf)+n, count-n); if (ret > 0) { n += ret; @@ -363,6 +364,7 @@ size_t n = 0; do { + errno = 0; ret = read(req->fd, ((char*)buf)+n, count-n); if (ret > 0) { n += ret; -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /sapi/cgi fastcgi.c
dmitry Tue Dec 5 08:55:34 2006 UTC Modified files: /php-src/sapi/cgi fastcgi.c Log: Fixed FastCGI impersonation for persistent connections on Windows http://cvs.php.net/viewvc.cgi/php-src/sapi/cgi/fastcgi.c?r1=1.25&r2=1.26&diff_format=u Index: php-src/sapi/cgi/fastcgi.c diff -u php-src/sapi/cgi/fastcgi.c:1.25 php-src/sapi/cgi/fastcgi.c:1.26 --- php-src/sapi/cgi/fastcgi.c:1.25 Mon Oct 16 10:47:23 2006 +++ php-src/sapi/cgi/fastcgi.c Tue Dec 5 08:55:34 2006 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: fastcgi.c,v 1.25 2006/10/16 10:47:23 dmitry Exp $ */ +/* $Id: fastcgi.c,v 1.26 2006/12/05 08:55:34 dmitry Exp $ */ #include "php.h" #include "fastcgi.h" @@ -616,6 +616,13 @@ if (destroy) { zend_hash_destroy(&req->env); } + +#ifdef _WIN32 + if (is_impersonate) { + RevertToSelf(); + } +#endif + if ((force || !req->keep) && req->fd >= 0) { #ifdef _WIN32 HANDLE pipe = (HANDLE)_get_osfhandle(req->fd); @@ -624,9 +631,6 @@ FlushFileBuffers(pipe); } DisconnectNamedPipe(pipe); - if (is_impersonate) { - RevertToSelf(); - } #else if (!force) { char buf[8]; @@ -673,12 +677,7 @@ } } CloseHandle(ov.hEvent); - if (is_impersonate && !ImpersonateNamedPipeClient(pipe)) { - DisconnectNamedPipe(pipe); - req->fd = -1; - } else { - req->fd = req->listen_socket; - } + req->fd = req->listen_socket; FCGI_UNLOCK(req->listen_socket); #else { @@ -718,6 +717,15 @@ return -1; } if (fcgi_read_request(req)) { +#ifdef _WIN32 + if (is_impersonate) { + pipe = (HANDLE)_get_osfhandle(req->fd); + if (!ImpersonateNamedPipeClient(pipe)) { + fcgi_close(req, 1, 1); + continue; + } + } +#endif return req->fd; } else { fcgi_close(req, 1, 1); -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /sapi/cgi fastcgi.c
dmitry Mon Oct 16 10:47:23 2006 UTC Modified files: /php-src/sapi/cgi fastcgi.c Log: Fixed bug #39020 (PHP in FastCGI server mode crashes) http://cvs.php.net/viewvc.cgi/php-src/sapi/cgi/fastcgi.c?r1=1.24&r2=1.25&diff_format=u Index: php-src/sapi/cgi/fastcgi.c diff -u php-src/sapi/cgi/fastcgi.c:1.24 php-src/sapi/cgi/fastcgi.c:1.25 --- php-src/sapi/cgi/fastcgi.c:1.24 Wed Sep 13 13:03:14 2006 +++ php-src/sapi/cgi/fastcgi.c Mon Oct 16 10:47:23 2006 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: fastcgi.c,v 1.24 2006/09/13 13:03:14 dmitry Exp $ */ +/* $Id: fastcgi.c,v 1.25 2006/10/16 10:47:23 dmitry Exp $ */ #include "php.h" #include "fastcgi.h" @@ -390,13 +390,14 @@ return pad; } -static void fcgi_get_params(fcgi_request *req, unsigned char *p, unsigned char *end) +static int fcgi_get_params(fcgi_request *req, unsigned char *p, unsigned char *end) { char buf[128]; char *tmp = buf; int buf_size = sizeof(buf); int name_len, val_len; char *s; + int ret = 1; while (p < end) { name_len = *p++; @@ -413,6 +414,11 @@ val_len |= (*p++ << 8); val_len |= *p++; } + if (p + name_len + val_len > end) { + /* Malformated request */ + ret = 0; + break; + } if (name_len+1 >= buf_size) { buf_size = name_len + 64; tmp = (tmp == buf ? emalloc(buf_size): erealloc(tmp, buf_size)); @@ -426,6 +432,7 @@ if (tmp != buf && tmp != NULL) { efree(tmp); } + return ret; } static void fcgi_free_var(char **s) @@ -503,7 +510,11 @@ req->keep = 0; return 0; } - fcgi_get_params(req, buf, buf+len); + + if (!fcgi_get_params(req, buf, buf+len)) { + req->keep = 0; + return 0; + } if (safe_read(req, &hdr, sizeof(fcgi_header)) != sizeof(fcgi_header) || hdr.version < FCGI_VERSION_1) { @@ -518,9 +529,14 @@ unsigned char *p = buf + sizeof(fcgi_header); if (safe_read(req, buf, len+padding) != len+padding) { + req->keep = 0; + return 0; + } + + if (!fcgi_get_params(req, buf, buf+len)) { + req->keep = 0; return 0; } - fcgi_get_params(req, buf, buf+len); for (j = 0; j < sizeof(fcgi_mgmt_vars)/sizeof(fcgi_mgmt_vars[0]); j++) { if (zend_hash_exists(&req->env, fcgi_mgmt_vars[j].name, fcgi_mgmt_vars[j].name_len+1) == 0) { @@ -531,6 +547,7 @@ len = p - buf - sizeof(fcgi_header); len += fcgi_make_header((fcgi_header*)buf, FCGI_GET_VALUES_RESULT, 0, len); if (safe_write(req, buf, sizeof(fcgi_header)+len) != (int)sizeof(fcgi_header)+len) { + req->keep = 0; return 0; } return 0; -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /sapi/cgi fastcgi.c
dmitry Wed Sep 13 13:03:14 2006 UTC Modified files: /php-src/sapi/cgi fastcgi.c Log: Fix for bug #38757 (MultiPart Form Uploads fail with FastCGI) http://cvs.php.net/viewvc.cgi/php-src/sapi/cgi/fastcgi.c?r1=1.23&r2=1.24&diff_format=u Index: php-src/sapi/cgi/fastcgi.c diff -u php-src/sapi/cgi/fastcgi.c:1.23 php-src/sapi/cgi/fastcgi.c:1.24 --- php-src/sapi/cgi/fastcgi.c:1.23 Mon Sep 11 07:23:40 2006 +++ php-src/sapi/cgi/fastcgi.c Wed Sep 13 13:03:14 2006 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: fastcgi.c,v 1.23 2006/09/11 07:23:40 dmitry Exp $ */ +/* $Id: fastcgi.c,v 1.24 2006/09/13 13:03:14 dmitry Exp $ */ #include "php.h" #include "fastcgi.h" @@ -682,7 +682,7 @@ break; #else if (req->fd >= 0) { - struct timeval tv = {1,0}; + struct timeval tv = {5,0}; fd_set set; FD_ZERO(&set); -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /sapi/cgi fastcgi.c
dmitry Mon Sep 11 07:23:40 2006 UTC Modified files: /php-src/sapi/cgi fastcgi.c Log: Don't try to do safe connection close in case of FastCGI protocol error http://cvs.php.net/viewvc.cgi/php-src/sapi/cgi/fastcgi.c?r1=1.22&r2=1.23&diff_format=u Index: php-src/sapi/cgi/fastcgi.c diff -u php-src/sapi/cgi/fastcgi.c:1.22 php-src/sapi/cgi/fastcgi.c:1.23 --- php-src/sapi/cgi/fastcgi.c:1.22 Mon Sep 4 07:27:50 2006 +++ php-src/sapi/cgi/fastcgi.c Mon Sep 11 07:23:40 2006 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: fastcgi.c,v 1.22 2006/09/04 07:27:50 dmitry Exp $ */ +/* $Id: fastcgi.c,v 1.23 2006/09/11 07:23:40 dmitry Exp $ */ #include "php.h" #include "fastcgi.h" @@ -611,10 +611,12 @@ RevertToSelf(); } #else - char buf[8]; + if (!force) { + char buf[8]; - shutdown(req->fd, 1); - while (recv(req->fd, buf, sizeof(buf), 0) > 0) {} + shutdown(req->fd, 1); + while (recv(req->fd, buf, sizeof(buf), 0) > 0) {} + } close(req->fd); #endif req->fd = -1; -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /sapi/cgi fastcgi.c
dmitry Mon Sep 4 07:27:50 2006 UTC Modified files: /php-src/sapi/cgi fastcgi.c Log: Fixed "signed/unsigned mismatch" warning http://cvs.php.net/viewvc.cgi/php-src/sapi/cgi/fastcgi.c?r1=1.21&r2=1.22&diff_format=u Index: php-src/sapi/cgi/fastcgi.c diff -u php-src/sapi/cgi/fastcgi.c:1.21 php-src/sapi/cgi/fastcgi.c:1.22 --- php-src/sapi/cgi/fastcgi.c:1.21 Sun Aug 20 17:44:06 2006 +++ php-src/sapi/cgi/fastcgi.c Mon Sep 4 07:27:50 2006 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: fastcgi.c,v 1.21 2006/08/20 17:44:06 sas Exp $ */ +/* $Id: fastcgi.c,v 1.22 2006/09/04 07:27:50 dmitry Exp $ */ #include "php.h" #include "fastcgi.h" @@ -394,7 +394,7 @@ { char buf[128]; char *tmp = buf; - size_t buf_size = sizeof(buf); + int buf_size = sizeof(buf); int name_len, val_len; char *s; -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /sapi/cgi fastcgi.c
sas Sun Aug 20 17:44:06 2006 UTC Modified files: /php-src/sapi/cgi fastcgi.c Log: "sa_len" is defined to "sa_union . sa_generic . sa_len2" on IRIX, so we use another variable name here. http://cvs.php.net/viewvc.cgi/php-src/sapi/cgi/fastcgi.c?r1=1.20&r2=1.21&diff_format=u Index: php-src/sapi/cgi/fastcgi.c diff -u php-src/sapi/cgi/fastcgi.c:1.20 php-src/sapi/cgi/fastcgi.c:1.21 --- php-src/sapi/cgi/fastcgi.c:1.20 Tue Jun 13 13:55:32 2006 +++ php-src/sapi/cgi/fastcgi.c Sun Aug 20 17:44:06 2006 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: fastcgi.c,v 1.20 2006/06/13 13:55:32 dmitry Exp $ */ +/* $Id: fastcgi.c,v 1.21 2006/08/20 17:44:06 sas Exp $ */ #include "php.h" #include "fastcgi.h" @@ -252,7 +252,7 @@ short port = 0; int listen_socket; sa_t sa; - socklen_t sa_len; + socklen_t sock_len; if ((s = strchr(path, ':'))) { port = atoi(s+1); @@ -268,7 +268,7 @@ memset(&sa.sa_inet, 0, sizeof(sa.sa_inet)); sa.sa_inet.sin_family = AF_INET; sa.sa_inet.sin_port = htons(port); - sa_len = sizeof(sa.sa_inet); + sock_len = sizeof(sa.sa_inet); if (!*host || !strncmp(host, "*", sizeof("*")-1)) { sa.sa_inet.sin_addr.s_addr = htonl(INADDR_ANY); @@ -299,16 +299,16 @@ memset(&sa.sa_unix, 0, sizeof(sa.sa_unix)); sa.sa_unix.sun_family = AF_UNIX; memcpy(sa.sa_unix.sun_path, path, path_len + 1); - sa_len = (size_t)(((struct sockaddr_un *)0)->sun_path) + path_len; + sock_len = (size_t)(((struct sockaddr_un *)0)->sun_path) + path_len; #ifdef HAVE_SOCKADDR_UN_SUN_LEN - sa.sa_unix.sun_len = sa_len; + sa.sa_unix.sun_len = sock_len; #endif unlink(path); } /* Create, bind socket and start listen on it */ if ((listen_socket = socket(sa.sa.sa_family, SOCK_STREAM, 0)) < 0 || - bind(listen_socket, (struct sockaddr *) &sa, sa_len) < 0 || + bind(listen_socket, (struct sockaddr *) &sa, sock_len) < 0 || listen(listen_socket, backlog) < 0) { fprintf(stderr, "Cannot bind/listen socket - [%d] %s.\n",errno, strerror(errno)); -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /sapi/cgi fastcgi.c
dmitry Tue Jun 13 13:55:32 2006 UTC Modified files: /php-src/sapi/cgi fastcgi.c Log: Removed warning http://cvs.php.net/viewcvs.cgi/php-src/sapi/cgi/fastcgi.c?r1=1.19&r2=1.20&diff_format=u Index: php-src/sapi/cgi/fastcgi.c diff -u php-src/sapi/cgi/fastcgi.c:1.19 php-src/sapi/cgi/fastcgi.c:1.20 --- php-src/sapi/cgi/fastcgi.c:1.19 Thu May 25 06:40:47 2006 +++ php-src/sapi/cgi/fastcgi.c Tue Jun 13 13:55:32 2006 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: fastcgi.c,v 1.19 2006/05/25 06:40:47 dmitry Exp $ */ +/* $Id: fastcgi.c,v 1.20 2006/06/13 13:55:32 dmitry Exp $ */ #include "php.h" #include "fastcgi.h" @@ -719,7 +719,7 @@ if (req->out_hdr) { int len = req->out_pos - ((unsigned char*)req->out_hdr + sizeof(fcgi_header)); - req->out_pos += fcgi_make_header(req->out_hdr, req->out_hdr->type, req->id, len); + req->out_pos += fcgi_make_header(req->out_hdr, (fcgi_request_type)req->out_hdr->type, req->id, len); req->out_hdr = NULL; } } -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /sapi/cgi fastcgi.c
dmitry Thu May 25 06:40:47 2006 UTC Modified files: /php-src/sapi/cgi fastcgi.c Log: Fixed bug #37496 (FastCGI output buffer overrun) http://cvs.php.net/viewcvs.cgi/php-src/sapi/cgi/fastcgi.c?r1=1.18&r2=1.19&diff_format=u Index: php-src/sapi/cgi/fastcgi.c diff -u php-src/sapi/cgi/fastcgi.c:1.18 php-src/sapi/cgi/fastcgi.c:1.19 --- php-src/sapi/cgi/fastcgi.c:1.18 Mon May 22 09:23:01 2006 +++ php-src/sapi/cgi/fastcgi.c Thu May 25 06:40:47 2006 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: fastcgi.c,v 1.18 2006/05/22 09:23:01 dmitry Exp $ */ +/* $Id: fastcgi.c,v 1.19 2006/05/25 06:40:47 dmitry Exp $ */ #include "php.h" #include "fastcgi.h" @@ -798,6 +798,7 @@ limit = sizeof(req->out_buf) - (req->out_pos - req->out_buf); if (!req->out_hdr) { limit -= sizeof(fcgi_header); + if (limit < 0) limit = 0; } if (len < limit) { @@ -810,8 +811,10 @@ if (!req->out_hdr) { open_packet(req, type); } - memcpy(req->out_pos, str, limit); - req->out_pos += limit; + if (limit > 0) { + memcpy(req->out_pos, str, limit); + req->out_pos += limit; + } if (!fcgi_flush(req, 0)) { return -1; } -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /sapi/cgi fastcgi.c
dmitry Mon May 22 09:23:01 2006 UTC Modified files: /php-src/sapi/cgi fastcgi.c Log: Fixed bug #37496 (FastCGI output buffer overrun) http://cvs.php.net/viewcvs.cgi/php-src/sapi/cgi/fastcgi.c?r1=1.17&r2=1.18&diff_format=u Index: php-src/sapi/cgi/fastcgi.c diff -u php-src/sapi/cgi/fastcgi.c:1.17 php-src/sapi/cgi/fastcgi.c:1.18 --- php-src/sapi/cgi/fastcgi.c:1.17 Mon May 22 06:49:44 2006 +++ php-src/sapi/cgi/fastcgi.c Mon May 22 09:23:01 2006 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: fastcgi.c,v 1.17 2006/05/22 06:49:44 tony2001 Exp $ */ +/* $Id: fastcgi.c,v 1.18 2006/05/22 09:23:01 dmitry Exp $ */ #include "php.h" #include "fastcgi.h" @@ -764,15 +764,17 @@ if (req->out_hdr && req->out_hdr->type != type) { close_packet(req); } - rest = len; #if 0 - /* Unoptinmzed, but clear version */ + /* Unoptimized, but clear version */ + rest = len; while (rest > 0) { limit = sizeof(req->out_buf) - (req->out_pos - req->out_buf); if (!req->out_hdr) { if (limit < sizeof(fcgi_header)) { - fcgi_flush(req, 0); + if (!fcgi_flush(req, 0)) { + return -1; + } } open_packet(req, type); } @@ -786,32 +788,38 @@ req->out_pos += limit; rest -= limit; str += limit; - fcgi_flush(req, 0); + if (!fcgi_flush(req, 0)) { + return -1; + } } } #else - /* Optinmzed version */ + /* Optimized version */ + limit = sizeof(req->out_buf) - (req->out_pos - req->out_buf); if (!req->out_hdr) { - rest += sizeof(fcgi_header); + limit -= sizeof(fcgi_header); } - limit = sizeof(req->out_buf) - (req->out_pos - req->out_buf); - if (rest < limit) { + if (len < limit) { if (!req->out_hdr) { open_packet(req, type); } memcpy(req->out_pos, str, len); req->out_pos += len; - } else if (rest - limit < sizeof(req->out_buf) - sizeof(fcgi_header)) { + } else if (len - limit < sizeof(req->out_buf) - sizeof(fcgi_header)) { if (!req->out_hdr) { open_packet(req, type); } memcpy(req->out_pos, str, limit); req->out_pos += limit; - fcgi_flush(req, 0); - open_packet(req, type); - memcpy(req->out_pos, str + limit, len - limit); - req->out_pos += len - limit; + if (!fcgi_flush(req, 0)) { + return -1; + } + if (len > limit) { + open_packet(req, type); + memcpy(req->out_pos, str + limit, len - limit); + req->out_pos += len - limit; + } } else { int pos = 0; int pad; @@ -821,7 +829,9 @@ open_packet(req, type); fcgi_make_header(req->out_hdr, type, req->id, 0xfff8); req->out_hdr = NULL; - fcgi_flush(req, 0); + if (!fcgi_flush(req, 0)) { + return -1; + } if (safe_write(req, str + pos, 0xfff8) != 0xfff8) { req->keep = 0; return -1; @@ -835,7 +845,9 @@ open_packet(req, type); fcgi_make_header(req->out_hdr, type, req->id, (len - pos) - rest); req->out_hdr = NULL; - fcgi_flush(req, 0); + if (!fcgi_flush(req, 0)) { + return -1; + } if (safe_write(req, str + pos, (len - pos) - rest) != (len - pos) - rest) { req->keep = 0; return -1; -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /sapi/cgi fastcgi.c
tony2001Mon May 22 06:49:44 2006 UTC Modified files: /php-src/sapi/cgi fastcgi.c Log: fix typo http://cvs.php.net/viewcvs.cgi/php-src/sapi/cgi/fastcgi.c?r1=1.16&r2=1.17&diff_format=u Index: php-src/sapi/cgi/fastcgi.c diff -u php-src/sapi/cgi/fastcgi.c:1.16 php-src/sapi/cgi/fastcgi.c:1.17 --- php-src/sapi/cgi/fastcgi.c:1.16 Mon May 15 14:30:50 2006 +++ php-src/sapi/cgi/fastcgi.c Mon May 22 06:49:44 2006 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: fastcgi.c,v 1.16 2006/05/15 14:30:50 dmitry Exp $ */ +/* $Id: fastcgi.c,v 1.17 2006/05/22 06:49:44 tony2001 Exp $ */ #include "php.h" #include "fastcgi.h" @@ -484,7 +484,7 @@ break; case FCGI_FILTER: val = strdup("FILTER"); - zend_hash_update(&req->env, "FCGI_ROLE", sizeof("FCGI_ROLE"), val, sizeof(char*), NULL); + zend_hash_update(&req->env, "FCGI_ROLE", sizeof("FCGI_ROLE"), &val, sizeof(char*), NULL); break; default: return 0; -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /sapi/cgi fastcgi.c
iliaa Tue May 9 22:00:36 2006 UTC Modified files: /php-src/sapi/cgi fastcgi.c Log: MFB: Fixed bug #37376 (fastcgi.c compile fail with gcc 2.95.4). http://cvs.php.net/viewcvs.cgi/php-src/sapi/cgi/fastcgi.c?r1=1.14&r2=1.15&diff_format=u Index: php-src/sapi/cgi/fastcgi.c diff -u php-src/sapi/cgi/fastcgi.c:1.14 php-src/sapi/cgi/fastcgi.c:1.15 --- php-src/sapi/cgi/fastcgi.c:1.14 Fri May 5 07:05:59 2006 +++ php-src/sapi/cgi/fastcgi.c Tue May 9 22:00:36 2006 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: fastcgi.c,v 1.14 2006/05/05 07:05:59 dmitry Exp $ */ +/* $Id: fastcgi.c,v 1.15 2006/05/09 22:00:36 iliaa Exp $ */ #include "fastcgi.h" #include "php.h" @@ -669,12 +669,14 @@ } FCGI_UNLOCK(req->listen_socket); #else - sa_t sa; - socklen_t len = sizeof(sa); - - FCGI_LOCK(req->listen_socket); - req->fd = accept(req->listen_socket, (struct sockaddr *)&sa, &len); - FCGI_UNLOCK(req->listen_socket); + { + sa_t sa; + socklen_t len = sizeof(sa); + + FCGI_LOCK(req->listen_socket); + req->fd = accept(req->listen_socket, (struct sockaddr *)&sa, &len); + FCGI_UNLOCK(req->listen_socket); + } #endif if (req->fd < 0 && (in_shutdown || errno != EINTR)) { -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /sapi/cgi fastcgi.c
dmitry Fri May 5 07:05:59 2006 UTC Modified files: /php-src/sapi/cgi fastcgi.c Log: Fixed bug #37313 (sigemptyset() used without including ). (jdolecek) http://cvs.php.net/viewcvs.cgi/php-src/sapi/cgi/fastcgi.c?r1=1.13&r2=1.14&diff_format=u Index: php-src/sapi/cgi/fastcgi.c diff -u php-src/sapi/cgi/fastcgi.c:1.13 php-src/sapi/cgi/fastcgi.c:1.14 --- php-src/sapi/cgi/fastcgi.c:1.13 Wed May 3 15:48:33 2006 +++ php-src/sapi/cgi/fastcgi.c Fri May 5 07:05:59 2006 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: fastcgi.c,v 1.13 2006/05/03 15:48:33 dmitry Exp $ */ +/* $Id: fastcgi.c,v 1.14 2006/05/05 07:05:59 dmitry Exp $ */ #include "fastcgi.h" #include "php.h" @@ -69,7 +69,7 @@ # include # include # include -# include +# include #ifndef INADDR_NONE #define INADDR_NONE ((unsigned long) -1) -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /sapi/cgi fastcgi.c fastcgi.h
dmitry Wed May 3 15:48:33 2006 UTC Modified files: /php-src/sapi/cgi fastcgi.c fastcgi.h Log: Fixed bug #37205 (incompatibility with mod_fastcgi) http://cvs.php.net/viewcvs.cgi/php-src/sapi/cgi/fastcgi.c?r1=1.12&r2=1.13&diff_format=u Index: php-src/sapi/cgi/fastcgi.c diff -u php-src/sapi/cgi/fastcgi.c:1.12 php-src/sapi/cgi/fastcgi.c:1.13 --- php-src/sapi/cgi/fastcgi.c:1.12 Wed May 3 13:20:12 2006 +++ php-src/sapi/cgi/fastcgi.c Wed May 3 15:48:33 2006 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: fastcgi.c,v 1.12 2006/05/03 13:20:12 dmitry Exp $ */ +/* $Id: fastcgi.c,v 1.13 2006/05/03 15:48:33 dmitry Exp $ */ #include "fastcgi.h" #include "php.h" @@ -305,7 +305,7 @@ memset(&sa.sa_unix, 0, sizeof(sa.sa_unix)); sa.sa_unix.sun_family = AF_UNIX; memcpy(sa.sa_unix.sun_path, path, path_len + 1); - sa_len = (size_t)(((struct sockaddr_un *)0)->sun_path) + path_len; + sa_len = (size_t)(((struct sockaddr_un *)0)->sun_path) + path_len; #ifdef HAVE_SOCKADDR_UN_SUN_LEN sa.sa_unix.sun_len = sa_len; #endif @@ -441,7 +441,6 @@ unsigned char buf[FCGI_MAX_LENGTH+8]; req->keep = 0; - req->has_in = 0; req->in_len = 0; req->out_hdr = NULL; req->out_pos = req->out_buf; @@ -510,19 +509,6 @@ len = (hdr.contentLengthB1 << 8) | hdr.contentLengthB0; padding = hdr.paddingLength; } -#ifdef _WIN32 - req->has_in = 1; -#else - if (safe_read(req, &hdr, sizeof(fcgi_header)) != sizeof(fcgi_header) || - hdr.version < FCGI_VERSION_1 || - hdr.type != FCGI_STDIN) { - req->keep = 0; - return 0; - } - req->in_len = (hdr.contentLengthB1 << 8) | hdr.contentLengthB0; - req->in_pad = hdr.paddingLength; - req->has_in = (req->in_len != 0); -#endif } else if (hdr.type == FCGI_GET_VALUES) { int i, j; int name_len; @@ -548,7 +534,7 @@ } len = p - buf - sizeof(fcgi_header); len += fcgi_make_header((fcgi_header*)buf, FCGI_GET_VALUES_RESULT, 0, len); - if (safe_write(req, buf, sizeof(fcgi_header)+len) != sizeof(fcgi_header)+len) { + if (safe_write(req, buf, sizeof(fcgi_header)+len) != (int)sizeof(fcgi_header)+len) { return 0; } return 0; @@ -565,9 +551,6 @@ fcgi_header hdr; unsigned char buf[8]; - if (!req->has_in) { - return 0; - } n = 0; rest = len; while (rest > 0) { @@ -635,6 +618,10 @@ RevertToSelf(); } #else + char buf[8]; + + shutdown(req->fd, 1); + while (recv(req->fd, buf, sizeof(buf), 0) > 0) {} close(req->fd); #endif req->fd = -1; http://cvs.php.net/viewcvs.cgi/php-src/sapi/cgi/fastcgi.h?r1=1.3&r2=1.4&diff_format=u Index: php-src/sapi/cgi/fastcgi.h diff -u php-src/sapi/cgi/fastcgi.h:1.3 php-src/sapi/cgi/fastcgi.h:1.4 --- php-src/sapi/cgi/fastcgi.h:1.3 Thu Apr 27 11:39:46 2006 +++ php-src/sapi/cgi/fastcgi.h Wed May 3 15:48:33 2006 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: fastcgi.h,v 1.3 2006/04/27 11:39:46 dmitry Exp $ */ +/* $Id: fastcgi.h,v 1.4 2006/05/03 15:48:33 dmitry Exp $ */ /* FastCGI protocol */ @@ -97,7 +97,6 @@ intid; intkeep; - inthas_in; intin_len; intin_pad; -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /sapi/cgi fastcgi.c
dmitry Wed May 3 13:20:13 2006 UTC Modified files: /php-src/sapi/cgi fastcgi.c Log: Fixed incompatibility with isapi_fcgi.dll http://cvs.php.net/viewcvs.cgi/php-src/sapi/cgi/fastcgi.c?r1=1.11&r2=1.12&diff_format=u Index: php-src/sapi/cgi/fastcgi.c diff -u php-src/sapi/cgi/fastcgi.c:1.11 php-src/sapi/cgi/fastcgi.c:1.12 --- php-src/sapi/cgi/fastcgi.c:1.11 Thu Apr 27 11:39:46 2006 +++ php-src/sapi/cgi/fastcgi.c Wed May 3 13:20:12 2006 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: fastcgi.c,v 1.11 2006/04/27 11:39:46 dmitry Exp $ */ +/* $Id: fastcgi.c,v 1.12 2006/05/03 13:20:12 dmitry Exp $ */ #include "fastcgi.h" #include "php.h" @@ -510,6 +510,9 @@ len = (hdr.contentLengthB1 << 8) | hdr.contentLengthB0; padding = hdr.paddingLength; } +#ifdef _WIN32 + req->has_in = 1; +#else if (safe_read(req, &hdr, sizeof(fcgi_header)) != sizeof(fcgi_header) || hdr.version < FCGI_VERSION_1 || hdr.type != FCGI_STDIN) { @@ -519,6 +522,7 @@ req->in_len = (hdr.contentLengthB1 << 8) | hdr.contentLengthB0; req->in_pad = hdr.paddingLength; req->has_in = (req->in_len != 0); +#endif } else if (hdr.type == FCGI_GET_VALUES) { int i, j; int name_len; -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /sapi/cgi fastcgi.c fastcgi.h
dmitry Thu Apr 27 11:39:46 2006 UTC Modified files: /php-src/sapi/cgi fastcgi.c fastcgi.h Log: Proper fix for bug #37205 http://cvs.php.net/viewcvs.cgi/php-src/sapi/cgi/fastcgi.c?r1=1.10&r2=1.11&diff_format=u Index: php-src/sapi/cgi/fastcgi.c diff -u php-src/sapi/cgi/fastcgi.c:1.10 php-src/sapi/cgi/fastcgi.c:1.11 --- php-src/sapi/cgi/fastcgi.c:1.10 Wed Apr 26 17:48:45 2006 +++ php-src/sapi/cgi/fastcgi.c Thu Apr 27 11:39:46 2006 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: fastcgi.c,v 1.10 2006/04/26 17:48:45 dmitry Exp $ */ +/* $Id: fastcgi.c,v 1.11 2006/04/27 11:39:46 dmitry Exp $ */ #include "fastcgi.h" #include "php.h" @@ -441,6 +441,7 @@ unsigned char buf[FCGI_MAX_LENGTH+8]; req->keep = 0; + req->has_in = 0; req->in_len = 0; req->out_hdr = NULL; req->out_pos = req->out_buf; @@ -509,6 +510,15 @@ len = (hdr.contentLengthB1 << 8) | hdr.contentLengthB0; padding = hdr.paddingLength; } + if (safe_read(req, &hdr, sizeof(fcgi_header)) != sizeof(fcgi_header) || + hdr.version < FCGI_VERSION_1 || + hdr.type != FCGI_STDIN) { + req->keep = 0; + return 0; + } + req->in_len = (hdr.contentLengthB1 << 8) | hdr.contentLengthB0; + req->in_pad = hdr.paddingLength; + req->has_in = (req->in_len != 0); } else if (hdr.type == FCGI_GET_VALUES) { int i, j; int name_len; @@ -551,6 +561,9 @@ fcgi_header hdr; unsigned char buf[8]; + if (!req->has_in) { + return 0; + } n = 0; rest = len; while (rest > 0) { http://cvs.php.net/viewcvs.cgi/php-src/sapi/cgi/fastcgi.h?r1=1.2&r2=1.3&diff_format=u Index: php-src/sapi/cgi/fastcgi.h diff -u php-src/sapi/cgi/fastcgi.h:1.2 php-src/sapi/cgi/fastcgi.h:1.3 --- php-src/sapi/cgi/fastcgi.h:1.2 Sun Jan 1 13:09:57 2006 +++ php-src/sapi/cgi/fastcgi.h Thu Apr 27 11:39:46 2006 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: fastcgi.h,v 1.2 2006/01/01 13:09:57 sniper Exp $ */ +/* $Id: fastcgi.h,v 1.3 2006/04/27 11:39:46 dmitry Exp $ */ /* FastCGI protocol */ @@ -97,6 +97,7 @@ intid; intkeep; + inthas_in; intin_len; intin_pad; -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /sapi/cgi fastcgi.c
dmitry Wed Apr 26 17:48:45 2006 UTC Modified files: /php-src/sapi/cgi fastcgi.c Log: Revert wrong fix http://cvs.php.net/viewcvs.cgi/php-src/sapi/cgi/fastcgi.c?r1=1.9&r2=1.10&diff_format=u Index: php-src/sapi/cgi/fastcgi.c diff -u php-src/sapi/cgi/fastcgi.c:1.9 php-src/sapi/cgi/fastcgi.c:1.10 --- php-src/sapi/cgi/fastcgi.c:1.9 Wed Apr 26 11:08:23 2006 +++ php-src/sapi/cgi/fastcgi.c Wed Apr 26 17:48:45 2006 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: fastcgi.c,v 1.9 2006/04/26 11:08:23 dmitry Exp $ */ +/* $Id: fastcgi.c,v 1.10 2006/04/26 17:48:45 dmitry Exp $ */ #include "fastcgi.h" #include "php.h" @@ -618,12 +618,8 @@ RevertToSelf(); } #else -#if 1 - shutdown(req->fd, 2); -#else close(req->fd); #endif -#endif req->fd = -1; } } @@ -857,8 +853,10 @@ int fcgi_finish_request(fcgi_request *req) { - fcgi_flush(req, 1); - fcgi_close(req, 0, 1); + if (req->fd >= 0) { + fcgi_flush(req, 1); + fcgi_close(req, 0, 1); + } return 1; } -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /sapi/cgi fastcgi.c
dmitry Wed Apr 26 11:08:23 2006 UTC Modified files: /php-src/sapi/cgi fastcgi.c Log: Fixed bug #37205 (Serving binary content/images fails with "comm with server aborted" FastCGI err) http://cvs.php.net/viewcvs.cgi/php-src/sapi/cgi/fastcgi.c?r1=1.8&r2=1.9&diff_format=u Index: php-src/sapi/cgi/fastcgi.c diff -u php-src/sapi/cgi/fastcgi.c:1.8 php-src/sapi/cgi/fastcgi.c:1.9 --- php-src/sapi/cgi/fastcgi.c:1.8 Mon Apr 24 09:56:56 2006 +++ php-src/sapi/cgi/fastcgi.c Wed Apr 26 11:08:23 2006 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: fastcgi.c,v 1.8 2006/04/24 09:56:56 dmitry Exp $ */ +/* $Id: fastcgi.c,v 1.9 2006/04/26 11:08:23 dmitry Exp $ */ #include "fastcgi.h" #include "php.h" @@ -618,8 +618,12 @@ RevertToSelf(); } #else +#if 1 + shutdown(req->fd, 2); +#else close(req->fd); #endif +#endif req->fd = -1; } } @@ -814,16 +818,30 @@ memcpy(req->out_pos, str + limit, len - limit); req->out_pos += len - limit; } else { - int pad = ((len + 7) & ~7) - len; + int pos = 0; + int pad; + close_packet(req); + while ((len - pos) > 0x) { + open_packet(req, type); + fcgi_make_header(req->out_hdr, type, req->id, 0xfff8); + req->out_hdr = NULL; + fcgi_flush(req, 0); + if (safe_write(req, str + pos, 0xfff8) != 0xfff8) { + req->keep = 0; + return -1; + } + pos += 0xfff8; + } + + pad = (((len - pos) + 7) & ~7) - (len - pos); rest = pad ? 8 - pad : 0; - close_packet(req); open_packet(req, type); - fcgi_make_header(req->out_hdr, type, req->id, len - rest); + fcgi_make_header(req->out_hdr, type, req->id, (len - pos) - rest); req->out_hdr = NULL; fcgi_flush(req, 0); - if (safe_write(req, str, len - rest) != len - rest) { + if (safe_write(req, str + pos, (len - pos) - rest) != (len - pos) - rest) { req->keep = 0; return -1; } -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /sapi/cgi fastcgi.c
dmitry Mon Apr 24 09:56:56 2006 UTC Modified files: /php-src/sapi/cgi fastcgi.c Log: Fixed compilation on Solaris http://cvs.php.net/viewcvs.cgi/php-src/sapi/cgi/fastcgi.c?r1=1.7&r2=1.8&diff_format=u Index: php-src/sapi/cgi/fastcgi.c diff -u php-src/sapi/cgi/fastcgi.c:1.7 php-src/sapi/cgi/fastcgi.c:1.8 --- php-src/sapi/cgi/fastcgi.c:1.7 Tue Apr 18 06:59:31 2006 +++ php-src/sapi/cgi/fastcgi.c Mon Apr 24 09:56:56 2006 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: fastcgi.c,v 1.7 2006/04/18 06:59:31 dmitry Exp $ */ +/* $Id: fastcgi.c,v 1.8 2006/04/24 09:56:56 dmitry Exp $ */ #include "fastcgi.h" #include "php.h" @@ -71,6 +71,10 @@ # include # include +#ifndef INADDR_NONE +#define INADDR_NONE ((unsigned long) -1) +#endif + # ifndef HAVE_SOCKLEN_T typedef unsigned int socklen_t; # endif -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /sapi/cgi fastcgi.c
dmitry Tue Apr 18 06:59:31 2006 UTC Modified files: /php-src/sapi/cgi fastcgi.c Log: Fixed SUN_LEN calculation http://cvs.php.net/viewcvs.cgi/php-src/sapi/cgi/fastcgi.c?r1=1.6&r2=1.7&diff_format=u Index: php-src/sapi/cgi/fastcgi.c diff -u php-src/sapi/cgi/fastcgi.c:1.6 php-src/sapi/cgi/fastcgi.c:1.7 --- php-src/sapi/cgi/fastcgi.c:1.6 Sat Feb 4 23:58:22 2006 +++ php-src/sapi/cgi/fastcgi.c Tue Apr 18 06:59:31 2006 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: fastcgi.c,v 1.6 2006/02/04 23:58:22 fmk Exp $ */ +/* $Id: fastcgi.c,v 1.7 2006/04/18 06:59:31 dmitry Exp $ */ #include "fastcgi.h" #include "php.h" @@ -301,9 +301,8 @@ memset(&sa.sa_unix, 0, sizeof(sa.sa_unix)); sa.sa_unix.sun_family = AF_UNIX; memcpy(sa.sa_unix.sun_path, path, path_len + 1); - sa_len = sizeof(sa.sa_unix.sun_family) + path_len; + sa_len = (size_t)(((struct sockaddr_un *)0)->sun_path) + path_len; #ifdef HAVE_SOCKADDR_UN_SUN_LEN - sa_len += sizeof(sa.sa_unix.sun_len) + 1; sa.sa_unix.sun_len = sa_len; #endif unlink(path); -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /sapi/cgi fastcgi.c
fmk Sat Feb 4 23:58:22 2006 UTC Modified files: /php-src/sapi/cgi fastcgi.c Log: MFB51 Fix build on win32 http://cvs.php.net/viewcvs.cgi/php-src/sapi/cgi/fastcgi.c?r1=1.5&r2=1.6&diff_format=u Index: php-src/sapi/cgi/fastcgi.c diff -u php-src/sapi/cgi/fastcgi.c:1.5 php-src/sapi/cgi/fastcgi.c:1.6 --- php-src/sapi/cgi/fastcgi.c:1.5 Fri Feb 3 16:30:27 2006 +++ php-src/sapi/cgi/fastcgi.c Sat Feb 4 23:58:22 2006 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: fastcgi.c,v 1.5 2006/02/03 16:30:27 dmitry Exp $ */ +/* $Id: fastcgi.c,v 1.6 2006/02/04 23:58:22 fmk Exp $ */ #include "fastcgi.h" #include "php.h" @@ -623,6 +623,10 @@ int fcgi_accept_request(fcgi_request *req) { +#ifdef _WIN32 + HANDLE pipe; + OVERLAPPED ov; +#endif fcgi_finish_request(req); while (1) { @@ -632,8 +636,7 @@ return -1; } #ifdef _WIN32 - HANDLE pipe = (HANDLE)_get_osfhandle(req->listen_socket); - OVERLAPPED ov; + pipe = (HANDLE)_get_osfhandle(req->listen_socket); FCGI_LOCK(req->listen_socket); ov.hEvent = CreateEvent(NULL, TRUE, FALSE, NULL); -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-CVS] cvs: php-src /sapi/cgi fastcgi.c fastcgi.h
Thank you Nono. I applied your patch. Dmitry. > -Original Message- > From: Nuno Lopes [mailto:[EMAIL PROTECTED] > Sent: Monday, December 26, 2005 1:24 PM > To: Zeev Suraski; php-cvs@lists.php.net > Cc: [EMAIL PROTECTED] > Subject: Re: [PHP-CVS] cvs: php-src /sapi/cgi fastcgi.c fastcgi.h > > > > zeev Mon Dec 26 07:25:45 2005 EDT > > > > Added files: > >/php-src/sapi/cgi fastcgi.c fastcgi.h > > Log: > > Commit missing files - sorry! > > > > I've made a little patch to fix compile warnings and to > define MAXPATHLEN > properly on windows (defined in php.h). > > http://mega.ist.utl.pt/~ncpl/php_fastcgi.txt > > Nuno > > -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /sapi/cgi fastcgi.c
dmitry Mon Dec 26 10:54:13 2005 EDT Modified files: /php-src/sapi/cgi fastcgi.c Log: Code cleanup (Nuno) http://cvs.php.net/viewcvs.cgi/php-src/sapi/cgi/fastcgi.c?r1=1.2&r2=1.3&diff_format=u Index: php-src/sapi/cgi/fastcgi.c diff -u php-src/sapi/cgi/fastcgi.c:1.2 php-src/sapi/cgi/fastcgi.c:1.3 --- php-src/sapi/cgi/fastcgi.c:1.2 Mon Dec 26 07:56:37 2005 +++ php-src/sapi/cgi/fastcgi.c Mon Dec 26 10:54:12 2005 @@ -16,9 +16,10 @@ +--+ */ -/* $Id: fastcgi.c,v 1.2 2005/12/26 07:56:37 sebastian Exp $ */ +/* $Id: fastcgi.c,v 1.3 2005/12/26 10:54:12 dmitry Exp $ */ #include "fastcgi.h" +#include "php.h" #include #include @@ -26,23 +27,10 @@ #include #include -#ifndef MAXPATHLEN -# ifdef PATH_MAX -#define MAXPATHLEN PATH_MAX -# else -#define MAXPATHLEN 512 -# endif -#endif - #ifdef _WIN32 #include -# define inline__inline -# define vsnprintf _vsnprintf - - typedef int socklen_t; - typedef int ssize_t; typedef unsigned int size_t; struct sockaddr_un { @@ -72,7 +60,6 @@ #else -# include "php_config.h" # include # include # include -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-CVS] cvs: php-src /sapi/cgi fastcgi.c fastcgi.h
zeev Mon Dec 26 07:25:45 2005 EDT Added files: /php-src/sapi/cgi fastcgi.c fastcgi.h Log: Commit missing files - sorry! I've made a little patch to fix compile warnings and to define MAXPATHLEN properly on windows (defined in php.h). http://mega.ist.utl.pt/~ncpl/php_fastcgi.txt Nuno -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /sapi/cgi fastcgi.c
sebastian Mon Dec 26 07:56:38 2005 EDT Modified files: /php-src/sapi/cgi fastcgi.c Log: Fix Windows build. http://cvs.php.net/viewcvs.cgi/php-src/sapi/cgi/fastcgi.c?r1=1.1&r2=1.2&diff_format=u Index: php-src/sapi/cgi/fastcgi.c diff -u php-src/sapi/cgi/fastcgi.c:1.1 php-src/sapi/cgi/fastcgi.c:1.2 --- php-src/sapi/cgi/fastcgi.c:1.1 Mon Dec 26 07:25:45 2005 +++ php-src/sapi/cgi/fastcgi.c Mon Dec 26 07:56:37 2005 @@ -16,9 +16,8 @@ +--+ */ -/* $Id: fastcgi.c,v 1.1 2005/12/26 07:25:45 zeev Exp $ */ +/* $Id: fastcgi.c,v 1.2 2005/12/26 07:56:37 sebastian Exp $ */ -#include "php_config.h" #include "fastcgi.h" #include @@ -73,6 +72,7 @@ #else +# include "php_config.h" # include # include # include -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /sapi/cgi fastcgi.c fastcgi.h
zeevMon Dec 26 07:25:45 2005 EDT Added files: /php-src/sapi/cgi fastcgi.c fastcgi.h Log: Commit missing files - sorry! http://cvs.php.net/viewcvs.cgi/php-src/sapi/cgi/fastcgi.c?view=markup&rev=1.1 Index: php-src/sapi/cgi/fastcgi.c +++ php-src/sapi/cgi/fastcgi.c /* +--+ | PHP Version 5| +--+ | Copyright (c) 1997-2005 The PHP Group| +--+ | This source file is subject to version 3.0 of the PHP license, | | that is bundled with this package in the file LICENSE, and is| | available through the world-wide-web at the following url: | | http://www.php.net/license/3_0.txt. | | If you did not receive a copy of the PHP license and are unable to | | obtain it through the world-wide-web, please send a note to | | [EMAIL PROTECTED] so we can mail you a copy immediately. | +--+ | Authors: Dmitry Stogov <[EMAIL PROTECTED]> | +--+ */ /* $Id: fastcgi.c,v 1.1 2005/12/26 07:25:45 zeev Exp $ */ #include "php_config.h" #include "fastcgi.h" #include #include #include #include #include #ifndef MAXPATHLEN # ifdef PATH_MAX #define MAXPATHLEN PATH_MAX # else #define MAXPATHLEN 512 # endif #endif #ifdef _WIN32 #include # define inline__inline # define vsnprintf _vsnprintf typedef int socklen_t; typedef int ssize_t; typedef unsigned int size_t; struct sockaddr_un { short sun_family; charsun_path[MAXPATHLEN]; }; static HANDLE fcgi_accept_mutex = INVALID_HANDLE_VALUE; static int is_impersonate = 0; #define FCGI_LOCK(fd) \ if (fcgi_accept_mutex != INVALID_HANDLE_VALUE) { \ DWORD ret; \ while ((ret = WaitForSingleObject(fcgi_accept_mutex, 1000)) == WAIT_TIMEOUT) { \ if (in_shutdown) return -1; \ } \ if (ret == WAIT_FAILED) { \ fprintf(stderr, "WaitForSingleObject() failed\n"); \ return -1; \ } \ } #define FCGI_UNLOCK(fd) \ if (fcgi_accept_mutex != INVALID_HANDLE_VALUE) { \ ReleaseMutex(fcgi_accept_mutex); \ } #else # include # include # include # include # include # include # include # include # include # include # ifndef HAVE_SOCKLEN_T typedef unsigned int socklen_t; # endif # ifdef USE_LOCKING # define FCGI_LOCK(fd) \ do { \ struct flock lock; \ lock.l_type = F_WRLCK; \ lock.l_start = 0; \ lock.l_whence = SEEK_SET; \ lock.l_len = 0; \ if (fcntl(fd, F_SETLKW, &lock) != -1) { \ break; \ } else if (errno != EINTR || in_shutdown) { \ return -1; \ } \ } while (1) # define FCGI_UNLOCK(fd) \ do { \ int orig_errno = errno; \ while (1) { \ struct flock lock; \ lock.l_type = F_UNLCK; \ lock.l_start = 0; \ lock.l_whence = SEEK_SET; \ lock.l_len = 0; \ if (fcntl(fd, F_SETLK, &lock) != -1) { \ break;