Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:5612 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 772 invoked by uid 1010); 20 Nov 2003 11:13:23 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 738 invoked from network); 20 Nov 2003 11:13:22 -0000 Received: from unknown (HELO from.ro) (194.102.255.9) by pb1.pair.com with SMTP; 20 Nov 2003 11:13:22 -0000 Received: from dtp-cable1.kappa.ro (dtp-cable1.kappa.ro [194.102.251.61]) (AUTH: LOGIN pdoru, TLS: TLSv1/SSLv3,168bits,DES-CBC3-SHA) by from.ro with esmtp; Thu, 20 Nov 2003 13:13:19 +0200 To: internals@lists.php.net Content-Type: multipart/mixed; boundary="=-TDqIXWrfWvTEtsNHSsBM" Organization: Message-ID: <1069326795.3409.56.camel@dtp.kappa.ro> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.2.2 (1.2.2-5) Date: 20 Nov 2003 13:13:15 +0200 Subject: [PATCH] sapi apache2 uninitialized content-length value From: pdoru@kappa.ro (Doru Petrescu) --=-TDqIXWrfWvTEtsNHSsBM Content-Type: text/plain Content-Transfer-Encoding: 7bit Hi, While playing with the upload progress meter I noticed that apache2 sapi implementation does not initialize the content-length sapi variable. Apache 1.3 sapi does! and so does ALL OTHER interfaces. A quick grep into the sources will reveal that only apache2handler and apache2filter does not initialize this. Is there a reason for this ? Or is just something that sliped ? I wrote a patch to fix this. see attached. tested and it works with no problem and correctly reports the content-length. It is very simple and straight forward. copy/paste from apache 1.3 interface. now, I just wish nobody will upload anything over 2GB - integer overflow will doom the upload. -- Best regards, Doru Petrescu Senior Software Engineer Astral Telecom Bucuresti --=-TDqIXWrfWvTEtsNHSsBM Content-Disposition: attachment; filename=patch.sapi_apache2_content_length.txt Content-Type: text/x-patch; name=patch.sapi_apache2_content_length.txt; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit diff -rubB orig/php-4.3.4/sapi/apache2filter/sapi_apache2.c php-4.3.4/sapi/apache2filter/sapi_apache2.c --- orig/php-4.3.4/sapi/apache2filter/sapi_apache2.c 2003-08-03 22:31:13.000000000 +0300 +++ php-4.3.4/sapi/apache2filter/sapi_apache2.c 2003-11-19 19:34:02.000000000 +0200 @@ -376,6 +376,7 @@ static void php_apache_request_ctor(ap_filter_t *f, php_struct *ctx TSRMLS_DC) { char *content_type; + char *content_length; const char *auth; PG(during_request_startup) = 0; @@ -393,6 +394,10 @@ SG(request_info).post_data = ctx->post_data; SG(request_info).post_data_length = ctx->post_len; efree(content_type); + + content_length = (char *) apr_table_get(f->r->headers_in, "Content-Length"); + SG(request_info).content_length = (content_length ? atoi(content_length) : 0); + apr_table_unset(f->r->headers_out, "Content-Length"); apr_table_unset(f->r->headers_out, "Last-Modified"); apr_table_unset(f->r->headers_out, "Expires"); diff -rubB orig/php-4.3.4/sapi/apache2handler/sapi_apache2.c php-4.3.4/sapi/apache2handler/sapi_apache2.c --- orig/php-4.3.4/sapi/apache2handler/sapi_apache2.c 2003-10-02 06:24:43.000000000 +0300 +++ php-4.3.4/sapi/apache2handler/sapi_apache2.c 2003-11-19 19:34:52.000000000 +0200 @@ -414,6 +414,7 @@ static void php_apache_request_ctor(request_rec *r, php_struct *ctx TSRMLS_DC) { char *content_type; + char *content_length; const char *auth; SG(sapi_headers).http_response_code = !r->status ? HTTP_OK : r->status; @@ -428,6 +429,9 @@ ap_set_content_type(r, apr_pstrdup(r->pool, content_type)); efree(content_type); + content_length = (char *) apr_table_get(f->r->headers_in, "Content-Length"); + SG(request_info).content_length = (content_length ? atoi(content_length) : 0); + apr_table_unset(r->headers_out, "Content-Length"); apr_table_unset(r->headers_out, "Last-Modified"); apr_table_unset(r->headers_out, "Expires"); --=-TDqIXWrfWvTEtsNHSsBM--