mirror of https://github.com/vitalif/grive2
Change m_str.replace back to insert + remove StringStream limit
parent
887da88c14
commit
df99954382
|
@ -23,13 +23,6 @@
|
|||
|
||||
namespace gr {
|
||||
|
||||
namespace
|
||||
{
|
||||
// the max size of the cached string. this is to prevent allocating
|
||||
// too much memory if client sends a line too long (i.e. DOS attack)
|
||||
const std::size_t capacity = 4096 ;
|
||||
}
|
||||
|
||||
StringStream::StringStream( const std::string& init ) :
|
||||
// FIXME avoid copy
|
||||
m_str( init ), m_pos( 0 )
|
||||
|
@ -48,10 +41,8 @@ std::size_t StringStream::Read( char *data, std::size_t size )
|
|||
|
||||
std::size_t StringStream::Write( const char *data, std::size_t size )
|
||||
{
|
||||
std::size_t count = std::min( size, capacity - m_str.size() ) ;
|
||||
m_str.replace( m_str.begin() + m_pos, m_str.begin() + m_pos + count, data, data+count ) ;
|
||||
m_pos += count ;
|
||||
return count ;
|
||||
m_str.insert( m_str.size(), data, size ) ;
|
||||
return size ;
|
||||
}
|
||||
|
||||
off_t StringStream::Seek( off_t offset, int whence )
|
||||
|
|
|
@ -30,11 +30,6 @@ namespace gr {
|
|||
StringStream is a DataStream back-end that uses std::string for storage.
|
||||
It is useful for unit tests and text parsing, especially when used with
|
||||
StreamParser.
|
||||
|
||||
StringStream has a limit on the maximum number of byte it stores. This
|
||||
is to prevent DOS attacks in which the client sends a lot of bytes before
|
||||
the delimiter (e.g. new-line characters) and the server is forced to hold
|
||||
all of them in memory.
|
||||
*/
|
||||
class StringStream : public SeekStream
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue