[htdig3-dev] Found the cause of read chunked bug!


Subject: [htdig3-dev] Found the cause of read chunked bug!
From: Robert La Ferla (robertlaferla@mediaone.net)
Date: Wed Dec 13 2000 - 14:23:30 PST


I think I found the cause of the read chunked bug in HtHTTP.cc

In the method:

int HtHTTP::ReadChunkedBody()

If the variable ChunkHeader is "", the sscanf() (at least under Linux)
returns garbage (a really high number.) So, chunk_size gets set to a
really high number so the while() loop never exits.

I don't know how chunked content supposed to work, so I don't think I
can give you a bug fix but this should be enough information for some
developer to use for a fix. i.e. Questions to be answered are: Why is
ChunkHeader set to ""? And what should the program do when this
happens?

Robert

 while (chunk_size > 0)
   {
      chunk = chunk_size;

      do {
        if (chunk > BSIZE) {
          rsize = BSIZE;
          if (debug>4)
            cout << "Read chunk partial: left=" << chunk << endl;
        } else {
          rsize = chunk;
        }
        chunk -= rsize;

        // Read Chunk data
        if (_connection.Read(buffer, rsize) == -1)
          return -1;

        length+=rsize;

        // Append the chunk-data to the contents of the response
        // ... but not more than _max_document_size...
        if (rsize > _max_document_size-_response._contents.length())
            rsize = _max_document_size-_response._contents.length();
        buffer[rsize] = 0;
        _response._contents.append(buffer, rsize);

      } while (chunk);

     // if (_connection.Read(buffer, chunk_size) == -1)
     // return -1;

      // Read CRLF - to be ignored
      _connection.Read_Line(ChunkHeader);

      // Read chunk-size and CRLF
      _connection.Read_Line(ChunkHeader);
      sscanf ((char *)ChunkHeader, "%x", &chunk_size);

      if (debug>4)
         cout << "Chunk-size: " << chunk_size << endl;
   }

------------------------------------
To unsubscribe from the htdig3-dev mailing list, send a message to
htdig3-dev-unsubscribe@htdig.org
You will receive a message to confirm this.



This archive was generated by hypermail 2b28 : Wed Dec 13 2000 - 14:34:33 PST