You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by Brian Behlendorf <br...@organic.com> on 1996/11/20 05:39:49 UTC
bread() patch
On Tue, 19 Nov 1996, Jim Jagielski wrote:
> Brian Behlendorf wrote:
> >
> > On Tue, 19 Nov 1996, Rob Hartill wrote:
> > > 1.2-dev still has this bug in it. get_client_block needs to
> > > check for the -1 error case from the call to bread().
> >
> > Okay, so, folks, what should get_client_block do if it gets a -1 from bread?
> > Dump the connection with an error? Or consider it equivalent to 0?
>
> Sounds like an error to me.
Is this along the right lines? If so there's another call to bread which would
need addressing.
I can't figure out what is the best way to break out an error from here - have
get_client_block return -1? That's not checked for either. The best thing I
can think of to do is log an error and stop reading input.
How does one build a test case for this?
Brian
taz [100] cvs diff -C3 http_protocol.c
Index: http_protocol.c
===================================================================
RCS file: /export/home/cvs/apache/src/http_protocol.c,v
retrieving revision 1.75
diff -C3 -r1.75 http_protocol.c
*** http_protocol.c 1996/11/14 07:35:49 1.75
--- http_protocol.c 1996/11/20 04:35:10
***************
*** 1155,1165 ****
--- 1156,1173 ----
long get_client_block (request_rec *r, char *buffer, int bufsiz)
{
long c, len_read, len_to_read = r->remaining;
+ char errstr[MAX_STRING_LEN];
if (!r->read_chunked) { /* Content-length read */
if (len_to_read > bufsiz)
len_to_read = bufsiz;
len_read = bread(r->connection->client, buffer, len_to_read);
+ if (len_to_read < 0) {
+ sprintf(errstr, "Unexpected close of connection from %s during input read",
+ get_remote_host(r->connection, r->per_dir_config, REMOTE_NAME));
+ log_error(errstr, r->server);
+ len_to_read = 0;
+ }
r->remaining -= len_read;
return len_read;
}
--=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=--
brian@organic.com www.apache.org hyperreal.com http://www.organic.com/JOBS