Bug in http_request_read

"Casey T. Deccio" <[email protected]>
Newsgroups gmane.network.nocat
Organization Sandia National Laboratories
Message-ID <[email protected]>
Hi,

I'm not sure the standard way to submit bug reports or patches, but I'll
send this to the list.  In http_request_read, the app stops reading from
the socket when the number of bytes read is less than those requested.
this will stop reading when the first full packet is received,
regardless of if the whole request has been received.  For browsers like
Mozilla and firefox, this will kill the connection before the POST data
has been received.  The attached diff fixes the problem by receiving all
the headers, then reading the value of "Content-length" past the
headers.

Casey

_______________________________________________
NoCat mailing list
[email protected]
http://lists.nocat.net/mailman/listinfo/nocat
diff.txt (text/plain, 1.1 KB)
194,197d193
<     gchar *c_len_hdr;
<     guint c_len;
<     guint tot_req_size;
<     gchar *hdr_end = NULL;
200,221c196,197
<     for (t = 0, n = BUFSIZ; h->buffer->len < MAX_REQUEST_SIZE &&
<           (hdr_end = strstr(h->buffer->str, "\r\n\r\n")) == NULL; t += n ) {
<       // g_message("entering read loop");
<       r = g_io_channel_read( h->sock, buf, BUFSIZ, &n );
<       // g_message("read loop: read %d bytes of %d (%d)", n, BUFSIZ, r);
<       if (r != G_IO_ERROR_NONE) {
<           g_warning( "read_http_request failure: %m" );
<           g_free(buf);
<           return 0;
<       }
<       buf[n] = '\0';
<       g_string_append(h->buffer, buf);
<     }
<     http_parse_header( h, h->buffer->str );
<     c_len_hdr = HEADER("Content-length");
<     if (c_len_hdr == NULL) {
<       c_len = 0;
<     } else {
<       c_len = atoi( c_len_hdr );
<     }
<     tot_req_size = hdr_end - h->buffer->str + 4 + c_len;
<     for (; t < tot_req_size; t += n ) {
---
>     for (t = 0, n = BUFSIZ; n == BUFSIZ &&
>           h->buffer->len < MAX_REQUEST_SIZE; t += n ) {
243a220
>       http_parse_header( h, h->buffer->str );
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.