[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#191930: marked as done (apache-common: mod_proxy breaks on pages with blank Reason-Phrase)



Your message dated Mon,  5 May 2003 15:50:20 +0000
with message-id <1052149820.3eb6883c7b031@mail.snowplow.org>
and subject line Upstream fixed this in 1.3.27
has caused the attached Bug report to be marked as done.

This means that you claim that the problem has been dealt with.
If this is not the case it is now your responsibility to reopen the
Bug report if necessary, and/or fix the problem forthwith.

(NB: If you are a system administrator and have no idea what I am
talking about this indicates a serious mail system misconfiguration
somewhere.  Please contact me immediately.)

Debian bug tracking system administrator
(administrator, Debian Bugs database)

--------------------------------------
Received: (at submit) by bugs.debian.org; 5 May 2003 01:38:01 +0000
>From martin@snowplow.org Sun May 04 20:37:59 2003
Return-path: <martin@snowplow.org>
Received: from turkey.mail.pas.earthlink.net [207.217.120.126] 
	by master.debian.org with esmtp (Exim 3.12 1 (Debian))
	id 19CUvX-0005mm-00; Sun, 04 May 2003 20:37:59 -0500
Received: from user-2inik4f.dialup.mindspring.com ([165.121.80.143] helo=cush.martinhouse.internal)
	by turkey.mail.pas.earthlink.net with esmtp (Exim 3.33 #1)
	id 19CUvM-0003E3-00; Sun, 04 May 2003 18:37:49 -0700
Received: from martind by cush.martinhouse.internal with local (Exim 3.36 #1 (Debian))
	id 19CUL2-0005HJ-00; Sun, 04 May 2003 21:00:16 -0400
Subject: apache-common: mod_proxy breaks on pages with blank Reason-Phrase
From: "Daniel Martin" <martin@snowplow.org>
To: "Debian Bug Tracking System" <submit@bugs.debian.org>
X-Mailer: reportbug 1.99.47
Date: Sun, 04 May 2003 21:00:16 -0400
Message-Id: <[🔎] E19CUL2-0005HJ-00@cush.martinhouse.internal>
Sender: Daniel Martin <martin@snowplow.org>
Delivered-To: submit@bugs.debian.org
X-Spam-Status: No, hits=-12.3 required=4.0
	tests=BAYES_10,HAS_PACKAGE,PATCH_UNIFIED_DIFF
	autolearn=ham version=2.53-bugs.debian.org_2003_04_23
X-Spam-Level: 
X-Spam-Checker-Version: SpamAssassin 2.53-bugs.debian.org_2003_04_23 (1.174.2.15-2003-03-30-exp)

Package: apache-common
Version: 1.3.26-1.1
Severity: normal
Tags: upstream patch

On pages with status lines that have an empty Reason-Phrase (that is,
pages whose status line is simply "HTTP/1.1 200 " or similar),
mod_proxy will insert an extra blank line between the HTTP status line
and the headers.

For example, here is the view of a simple cgi script through a broken
proxy - I pipe the output through cat -vte to show what's going on.

First, using no proxy:

cush:/$ nc cush 80 | cat -vte
GET /cgi-bin/nph-t HTTP/1.1
Host: cush

HTTP/1.1 200 $
Date: Sun May 4 20:27:46 EDT 2003$
Server: Apache/1.3.26 (Unix) Debian GNU/Linux mod_perl/1.26 mod_jk/1.1.0$
Connection: close$
Content-type: text/html$
$
<html><head><title>mytitle</title></head><body><p>Test.</p></body></html>$

Now, using a broken proxy:

cush:/$ nc cush 80 | cat -vte
GET http://localhost/cgi-bin/nph-t HTTP/1.1
Host: localhost

HTTP/1.1 200 $
^M$
Date: Mon, 05 May 2003 00:33:12 GMT^M$
Server: Apache/1.3.26 (Unix) Debian GNU/Linux mod_perl/1.26 mod_jk/1.1.0^M$
Content-type: text/html; charset=iso-8859-1^M$
X-Cache: MISS from www.martinhouse.internal^M$
Transfer-Encoding: chunked^M$
^M$
4a ^M$
<html><head><title>mytitle</title></head><body><p>Test.</p></body></html>$
^M$
0^M$
^M$

The end result of this is that browsers looking through a mod_proxy
proxy end up seeing the html source and headers instead of the
properly rendered HTML.  It gets worse when the response is supposed
to be a redirection of some kind.  (For example, visit
http://www.crosswire.org/sword/ in a browser while looking through a
mod_proxy cache)

This problem comes from a bug in proxy_util.c, in the function
ap_proxy_read_response_line - the problem is that ap_getline leaves
the buffer looking like this:

'H' 'T' 'T' 'P' '/' '1' '.' '1' ' ' '2' '0' '0' '\0' '\n' '\0' <other>

Where <other> is trailing garbage we don't care about.

Anyway, ap_getline leaves the buffer in this state because it trims
all trailing whitespace.  Then, around line 1610 of proxy_util.c, the
code does some short sighted (and, I believe, unnecessary)
manipulations which leave the buffer as:

'H' 'T' 'T' 'P' '/' '1' '.' '1' ' ' '2' '0' '0' ' ' '\n' '\0' <other>

This leads to the problem above.

Anyway, the fix is pretty simple: just drop the following patch in
debian/patches:

--- build-tree/apache_1.3.26/src/modules/proxy/proxy_util.c
+++ build-tree/apache_1.3.26/src/modules/proxy/proxy_util.c
@@ -1607,6 +1607,9 @@
         }
         *backasswards = 0;
 
+        /* Fix for the case when the remote Reason-Phrase (RFC2616) is empty 
+         * In that case, ap_getline trims the space after the status code */
+        if ('\0' == buffer[12]) buffer[13] = '\0';
         buffer[12] = '\0';
         r->status = atoi(&buffer[9]);
         buffer[12] = ' ';

This will ensure that mod_proxy emits an RFC-conformant status line
(the space after the status number is required), and removes the extra
blank line.  Another fix that works on Debian systems is to remove the
two lines that manipulate buffer[12], but I suspect that they're there
to deal with some odd atoi implementations on one of the myriad
machines apache compiles on.

Upstream has a bug (number 10052) in their bugzilla which is another
manifestation of this same bug.  However, the patch attached to that
bug doesn't really address the cause of the problem as much as the
symptom.  Also, the bug has been held in status "NEW" for over six
months, so I don't think that upstream's paying attention to it.

-- System Information:
Debian Release: testing/unstable
Architecture: i386
Kernel: Linux cush 2.4.20 #1 Wed Apr 9 19:06:03 EDT 2003 i686
Locale: LANG=en_US, LC_CTYPE=en_US

Versions of packages apache-common depends on:
ii  libc6                        2.3.1-16    GNU C Library: Shared libraries an
ii  libdb2                       2:2.7.7.0-8 The Berkeley database routines (ru
ii  libexpat1                    1.95.6-4    XML parsing C library - runtime li
ii  perl [perl5]                 5.6.1-8.2   Larry Wall's Practical Extraction 


---------------------------------------
Received: (at 191930-close) by bugs.debian.org; 5 May 2003 15:50:52 +0000
>From martin@snowplow.org Mon May 05 10:50:51 2003
Return-path: <martin@snowplow.org>
Received: from gw.snowplow.org (beer.snowplow.org) [64.161.49.144] 
	by master.debian.org with esmtp (Exim 3.12 1 (Debian))
	id 19CiEt-0008VJ-00; Mon, 05 May 2003 10:50:51 -0500
Received: by beer.snowplow.org (Postfix, from userid 251)
	id 1A322157CAE; Mon,  5 May 2003 10:50:21 -0500 (CDT)
Received: from localhost (localhost.snowplow.org [127.0.0.1])
	by beer.snowplow.org (Postfix) with ESMTP id 89FC3157CAC
	for <191930-close@bugs.debian.org>; Mon,  5 May 2003 10:50:20 -0500 (CDT)
Received: from 192.88.60.254 ( [192.88.60.254])
	as user martin@localhost.snowplow.org by mail.snowplow.org with HTTP;
	Mon,  5 May 2003 15:50:20 +0000
Message-ID: <1052149820.3eb6883c7b031@mail.snowplow.org>
Date: Mon,  5 May 2003 15:50:20 +0000
From: Daniel Martin <martin@snowplow.org>
To: 191930-close@bugs.debian.org
Subject: Upstream fixed this in 1.3.27
MIME-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
User-Agent: Internet Messaging Program (IMP) 3.1
X-Bogosity: No, tests=bogofilter, spamicity=0.000000, version=0.11.1.8
Content-Transfer-Encoding: quoted-printable
Delivered-To: 191930-close@bugs.debian.org
X-Spam-Status: No, hits=-1.5 required=4.0
	tests=BAYES_10,USER_AGENT_IMP
	version=2.53-bugs.debian.org_2003_04_23
X-Spam-Level: 
X-Spam-Checker-Version: SpamAssassin 2.53-bugs.debian.org_2003_04_23 (1.174.2.15-2003-03-30-exp)

Upstream fixed this in version 1.3.27.

I personally think that my fix is better than the one they used, but they=
're
upstream and I'm not.  I'll be filling my patch as a performance wishlist=
 bug
with them.  (They do a strlen followed by a strcat, when a simple one-cha=
racter
=3D=3D check and one-character assignment is all that's needed)

This bug is closed since 1.3.27 has already hit unstable.

--=20
This is a signature virus.  Copy it.  NOW.



Reply to: