You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by Randy Terbush <ra...@zyzzyva.com> on 1996/07/21 22:30:01 UTC

Bug in set_content_length()

Bug?
Votes for or against inclusion please.


------- Forwarded Message

To: new-httpd@hyperreal.com
Subject: set_content_length() wrong
Message-ID: <Pi...@star>
MIME-Version: 1.0
Content-Type: TEXT/PLAIN; charset=US-ASCII
Sender: owner-new-httpd@hyperreal.com
Precedence: bulk
Reply-To: new-httpd@hyperreal.com

Gallotta Cristiano <cr...@pantelleria.dia.unisa.it> sent a report of
the following problem to me at Apache Week:
> Don't you think you should assign clength instead of finfo.st_size in
> the following ....
>
>  int set_content_length (request_rec *r, long clength)
> {
>    char ts[MAX_STRING_LEN];
>
>    sprintf (ts, "%ld", (long)r->finfo.st_size);
>    table_set (r->headers_out, "Content-length", pstrdup (r->pool, ts));
>    return 0;
> }

It looks wrong to me! set_content_length is called only once in Apache,
as:

     if ((errstatus = set_content_length (r, r->finfo.st_size))

in http_core.c (thus clength is set to the same value that is finally
assigned to the Content-length). But since set_content_length is available
to modules, this could be a problem if module authors start using it.

The fix patch is:

*** http_protocol.c.dist	Wed Jul  3 09:02:03 1996
- --- http_protocol.c	Wed Jul  3 09:01:51 1996
***************
*** 151,157 ****
  {
      char ts[MAX_STRING_LEN];

!     sprintf (ts, "%ld", (long)r->finfo.st_size);
      table_set (r->headers_out, "Content-length", pstrdup (r->pool, ts));
      return 0;
  }
- --- 151,157 ----
  {
      char ts[MAX_STRING_LEN];

!     sprintf (ts, "%ld", clength);
      table_set (r->headers_out, "Content-length", pstrdup (r->pool, ts));
      return 0;
  }

- --
Paul Sutton
UK Web Ltd




------- End of Forwarded Message




Re: Bug in set_content_length()

Posted by Alexei Kosut <ak...@organic.com>.
On Sun, 21 Jul 1996, Randy Terbush wrote:

> Bug?
> Votes for or against inclusion please.

*shrug* This is fixed in my HTTP/1.1 patch (which I'm currently working
right now on a revision of), but we could fix it seperately if we wanted.

-- Alexei Kosut <ak...@organic.com>            The Apache HTTP Server 
   http://www.nueva.pvt.k12.ca.us/~akosut/      http://www.apache.org/