mirror of
https://github.com/pocoproject/poco.git
synced 2024-12-13 10:32:57 +01:00
Fix writing into closed socket from streambuf
In case of error occured in writeToDevice pptr may become one byte farther than epptr. This can lead to crash in streambuf::xsputn from libstdc++.
This commit is contained in:
parent
94e9f2eec2
commit
c3d6fb94cc
@ -73,12 +73,12 @@ public:
|
||||
{
|
||||
if (!(_mode & IOS::out)) return char_traits::eof();
|
||||
|
||||
if (flushBuffer() == std::streamsize(-1)) return char_traits::eof();
|
||||
if (c != char_traits::eof())
|
||||
{
|
||||
*this->pptr() = char_traits::to_char_type(c);
|
||||
this->pbump(1);
|
||||
}
|
||||
if (flushBuffer() == std::streamsize(-1)) return char_traits::eof();
|
||||
|
||||
return c;
|
||||
}
|
||||
@ -127,7 +127,7 @@ protected:
|
||||
void resetBuffers()
|
||||
{
|
||||
this->setg(_pReadBuffer + 4, _pReadBuffer + 4, _pReadBuffer + 4);
|
||||
this->setp(_pWriteBuffer, _pWriteBuffer + (_bufsize - 1));
|
||||
this->setp(_pWriteBuffer, _pWriteBuffer + _bufsize);
|
||||
}
|
||||
|
||||
private:
|
||||
|
@ -60,7 +60,7 @@ public:
|
||||
_mode(mode)
|
||||
{
|
||||
this->setg(_pBuffer + 4, _pBuffer + 4, _pBuffer + 4);
|
||||
this->setp(_pBuffer, _pBuffer + (_bufsize - 1));
|
||||
this->setp(_pBuffer, _pBuffer + _bufsize);
|
||||
}
|
||||
|
||||
~BasicBufferedStreamBuf()
|
||||
@ -72,12 +72,12 @@ public:
|
||||
{
|
||||
if (!(_mode & IOS::out)) return char_traits::eof();
|
||||
|
||||
if (flushBuffer() == std::streamsize(-1)) return char_traits::eof();
|
||||
if (c != char_traits::eof())
|
||||
{
|
||||
*this->pptr() = char_traits::to_char_type(c);
|
||||
this->pbump(1);
|
||||
}
|
||||
if (flushBuffer() == std::streamsize(-1)) return char_traits::eof();
|
||||
|
||||
return c;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user