From apwww@hyperreal.org Thu Sep 11 14:45:29 1997 Received: (from apwww@localhost) by hyperreal.org (8.8.5/8.8.5) id OAA02042; Thu, 11 Sep 1997 14:45:29 -0700 (PDT) Message-Id: <199709112145.OAA02042@hyperreal.org> Date: Thu, 11 Sep 1997 14:45:29 -0700 (PDT) From: Nick Sayer Reply-To: nsayer@quack.kfu.com To: apbugs@hyperreal.org Subject: CGI output includes spurious Content-Type: header X-Send-Pr-Version: 3.2 >Number: 1122 >Category: os-freebsd >Synopsis: CGI output includes spurious Content-Type: header >Confidential: no >Severity: non-critical >Priority: medium >Responsible: apache >State: closed >Class: sw-bug >Submitter-Id: apache >Arrival-Date: Thu Sep 11 14:50:01 1997 >Last-Modified: Thu Sep 11 17:10:19 PDT 1997 >Originator: nsayer@quack.kfu.com >Organization: >Release: 1.2b6 & 1.3a1 >Environment: FreeBSD 2.2.2. Does _not_ happen with SunOS 4.1.x >Description: Sample session: POST /cgi-bin/page HTTP/1.0 Content-Length: 25 who=test&message=daklsjdasldjaskldalsHTTP/1.1 200 OK Date: Thu, 11 Sep 1997 21:43:11 GMT Server: Apache/1.3a1 Connection: close Content-Type: text/html Content-Type: text/html Page sent

Page sent.

The actual binary simply outputs the Content-type, a blank line, and the HTML. If I don't include the content type header, the type is sent as text/plain, but there is no duplicate header. >How-To-Repeat: The actual printf in the C source is printf("Content-Type: text/html\n\n"); later on the HTML is printed. >Fix: >Audit-Trail: State-Changed-From-To: open-analyzed State-Changed-By: marc State-Changed-When: Thu Sep 11 14:59:21 PDT 1997 State-Changed-Why: Please send the complete source for a _minimal_ program that replicates the behavior. It is likely a problem with your CGI. If you simply have it consist of nothing but the one line printf("Content-type: text/html\n\n") does it still give the same error? What if you try a GET instead of a POST? From: Marc Slemko To: Apache bugs database Subject: os-freebsd/1122 Date: Thu, 11 Sep 1997 16:03:28 -0600 (MDT) ---------- Forwarded message ---------- Date: Thu, 11 Sep 1997 14:59:29 -0700 (PDT) From: nobody@quack.kfu.com Reply-To: nsayer+xyzzy@quack.kfu.com To: Marc Slemko Subject: Unknown mailer filter Hi. I received your mail, but have NOT read it. Unfortunately, the rapidly increasing amount of unsolicited advertising via e-mail (junk e-mail or spam mail) has increased to such a point that I have been forced to start rejecting mail from unknown sources. If you are NOT sending me an unacceptable message (if you are in any doubt, carefully read the terms below), then please resend your message to "nsayer+xyzzy@quack.kfu.com". You will only have to ever do this once. You need not direct future e-mail to that special address as you will be added to my address book. For your convenience, you can also simply reply to this message. Your original message has been included at the end. To those of you inconvenienced by this procedure, I appologise. I hope, however, that you will lay the blame for this at the feet of those who are truly responsible: The people choking the net with spam. THE FOLLOWING TERMS APPLY ONLY TO UNINVITED SOLICITATIONS: I do not want to receive uninvited solicitations by email (Junk Email''). I am unwilling to receive Junk Email freely because it costs me time and money. If you send me any Junk Email other than on the terms of the offer set out in the following nine points, I will take this to mean that you plan to use what I offered you without paying for it. If you ever try to do this I reserve my right to take any action available to me without further reference to you. Actions available to me include taking proceedings against you for negligence or breach of contract, which may result in substantial damages being awarded against you by a court. The unauthorized use of my computing facilities may even be a crime. 1. I offer to receive all further email from you on the terms set out below. If you send me any solicitation by email without my express prior written consent this will be taken as your acceptance of this offer. 2. For the purposes of points 3 and 4, you will be taken to have sent any email sent by any entity apparently associated with you for the purpose of sending email solicitations. 3. You must pay me fifty US dollars for each such item of email that you send me. 4. You must pay me fifty US dollars for each copy of each email solicitation that you send to anybody or any email address referred to below, even if you don't send a copy to me. You may also have to pay other persons as well if they have sent you a similar offer. 5. I may join with any of those persons for the purpose of efficiently collecting your payments. 6. You must mail payment by certified check to me within five working days of the transmission of the email. If you do not know where to send payment, you must state this in the email and give me an easy way to tell you. 7. Each email item must be uniquely identified, and each payment must clearly identify the relevant item or items. 8. You must tell me your name and full business and residential addresses in each email message. 9. I may vary the terms of or terminate this offer at any time (even after you have accepted it). Any new terms will apply to all email you send after you have been notified of a variation. The copyright of the above text is held by Junkbusters Corporation and is used here in accordance with the GNU General Public License, copies of which are available at www.junkbusters.com or from the Free Software Foundation, 675 Massachusetts Avenue, Cambridge, MA 02139, USA. ------ ORIGINAL MESSAGE FOLLOWS ------ > From marc@hyperreal.org Thu Sep 11 14:59:27 1997 > Received: from hyperreal.org (taz.hyperreal.org [204.62.130.147]) by quack.kfu.com (8.8.5/8.6.12) with ESMTP id OAA25078 for ; Thu, 11 Sep 1997 14:59:24 -0700 (PDT) > Received: (from marc@localhost) > by hyperreal.org (8.8.5/8.8.5) id OAA07171; > Thu, 11 Sep 1997 14:59:22 -0700 (PDT) > Date: Thu, 11 Sep 1997 14:59:22 -0700 (PDT) > From: Marc Slemko > Message-Id: <199709112159.OAA07171@hyperreal.org> > To: apache-bugdb@apache.org, marc@apache.org, nsayer@quack.kfu.com > Subject: Re: os-freebsd/1122: CGI output includes spurious Content-Type: header > > Synopsis: CGI output includes spurious Content-Type: header > > State-Changed-From-To: open-analyzed > State-Changed-By: marc > State-Changed-When: Thu Sep 11 14:59:21 PDT 1997 > State-Changed-Why: > Please send the complete source for a _minimal_ program > that replicates the behavior. It is likely a problem > with your CGI. If you simply have it consist of nothing > but the one line printf("Content-type: text/html\n\n") does > it still give the same error? > > What if you try a GET instead of a POST? > From: Marc Slemko To: nsayer@quack.kfu.com Subject: os-freebsd/1122 Date: Thu, 11 Sep 1997 17:36:27 -0600 (MDT) On Thu, 11 Sep 1997 nsayer@quack.kfu.com wrote: > Marc Slemko writes: > > > Good grief. We really don't have the time to be manually > > jumping through hoops just to respond to you. > > Sorry. You won't have to anymore, though, having done it once. > My mailbox signal:noise ratio would be about 1:20 if I didn't > do it. Oh yea? Every time the status on the PR changes whoever changes it will manually have to forward the change to you since it comes from a different address. And I have to fix the subject line again for our bug tracking system, etc. Quite annoying. > > > > Please send the complete source for a _minimal_ program > > > > that replicates the behavior. > > Ok. > > #include > #include > #include > #include > > extern char *strdup(); > > main(argc,argv) > int argc; > char **argv; > { > struct post_env_list *list; > int pid; > > printf("Content-Type: text/html\n\n"); Add a fflush(stdout) here. stdout is buffered, so both child and parent end up writing it. As an alternative, you could use the appropriate setvbuf() call to disable buffering out stdout but that is less desirable because it adds more overhead. > > if ((pid=vfork())==0) > { > freopen("/dev/null","w",stdin); > freopen("/dev/null","w",stdout); > freopen("/dev/null","w",stderr); > exit(0); > } > else > waitpid(pid,NULL,0); > > printf("Page sent\n"); > printf("

Page sent.

\n"); > } > > > > It is likely a problem > > > > with your CGI. If you simply have it consist of nothing > > > > but the one line printf("Content-type: text/html\n\n") does > > > > it still give the same error? > > > > > > > > What if you try a GET instead of a POST? > > Same thing: > > GET /cgi-bin/foo HTTP/1.0 > > HTTP/1.1 200 OK > Date: Thu, 11 Sep 1997 22:18:46 GMT > Server: Apache/1.3a1 > Connection: close > Content-Type: text/html > > Content-Type: text/html > > Page sent >

Page sent.

> > -- > Nick Sayer http://www.kfu.com/~nsayer/ | > nsayer [at] quack [dot] kfu [dot] com | Tha average California Lottery > UNSOLICITED BULK EMAIL IS UNACCEPTABLE | ticket costs $1 and returns 50¢. > AND WILL BE CONSIDERED HARASSMENT | > From: Marc Slemko To: Apache bugs database Subject: Re: os-freebsd/1122 (fwd) Date: Thu, 11 Sep 1997 17:45:30 -0600 (MDT) ---------- Forwarded message ---------- Date: Thu, 11 Sep 1997 16:39:18 -0700 (PDT) From: nsayer@quack.kfu.com To: marcs@znep.com Subject: Re: os-freebsd/1122 Marc Slemko writes: > On Thu, 11 Sep 1997 nsayer@quack.kfu.com wrote: > > Marc Slemko writes: > >=20 > > > Good grief. We really don't have the time to be manually=20 > > > jumping through hoops just to respond to you. > >=20 > > Sorry. You won't have to anymore, though, having done it once. > > My mailbox signal:noise ratio would be about 1:20 if I didn't > > do it. > Oh yea? Every time the status on the PR changes whoever changes it will > manually have to forward the change to you since it comes from a different > address. And I have to fix the subject line again for our bug tracking > system, etc. Quite annoying.=20 *sigh* > > printf("Content-Type: text/html\n\n"); > Add a fflush(stdout) here. stdout is buffered, so both child and parent > end up writing it. Ah. I didn't think of that. Sounds like a bug in FreeBSD's stdio code then. Perhaps fork() should flush first or something. IMHO it's a bug if one write results in double traffic just because of a fork. But it's nothing to do with Apache. Thanks for your time. -- Nick Sayer http://www.kfu.com/~nsayer/ | Add to /usr/include/sys/errno.h: nsayer [at] quack [dot] kfu [dot] com | UNSOLICITED BULK EMAIL IS UNACCEPTABLE | #define EEMACS 666 /* Editor too big */ AND WILL BE CONSIDERED HARASSMENT | State-Changed-From-To: analyzed-closed State-Changed-By: marc State-Changed-When: Thu Sep 11 17:10:18 PDT 1997 State-Changed-Why: Flushing stdout fixed the problem. >Unformatted: