httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Randy Terbush <ra...@zyzzyva.com>
Subject Bug in set_content_length()
Date Sun, 21 Jul 1996 20:30:01 GMT

Bug?
Votes for or against inclusion please.


------- Forwarded Message

To: new-httpd@hyperreal.com
Subject: set_content_length() wrong
Message-ID: <Pine.LNX.3.92.960703082052.2115B-100000@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 <crigal@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




Mime
View raw message