Skip to content

Commit 2a6d58c

Browse files
committed
porting 1.4.4 rev. 1968 (fixed SF# 3559665, etc.)
1 parent dbda035 commit 2a6d58c

4 files changed

Lines changed: 27 additions & 8 deletions

File tree

Foundation/src/InflatingStream.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,6 @@ int InflatingStreamBuf::readFromDevice(char* buffer, std::streamsize length)
190190
_pIstr->read(_buffer, INFLATE_BUFFER_SIZE);
191191
n = static_cast<int>(_pIstr->gcount());
192192
}
193-
if (n == 0) return 0;
194193
_zstr.next_in = (unsigned char*) _buffer;
195194
_zstr.avail_in = n;
196195
}

Foundation/testsuite/src/ZLibTest.cpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,9 @@
3535
#include "CppUnit/TestSuite.h"
3636
#include "Poco/InflatingStream.h"
3737
#include "Poco/DeflatingStream.h"
38+
#include "Poco/MemoryStream.h"
3839
#include "Poco/StreamCopier.h"
40+
#include "Poco/Buffer.h"
3941
#include <sstream>
4042

4143

@@ -113,6 +115,22 @@ void ZLibTest::testDeflate3()
113115
}
114116

115117

118+
void ZLibTest::testDeflate4()
119+
{
120+
Poco::Buffer<char> buffer(1024);
121+
Poco::MemoryOutputStream ostr(buffer.begin(), static_cast<std::streamsize>(buffer.size()));
122+
DeflatingOutputStream deflater(ostr, -10, Z_BEST_SPEED);
123+
std::string data(36828, 'x');
124+
deflater << data;
125+
deflater.close();
126+
Poco::MemoryInputStream istr(buffer.begin(), ostr.charsWritten());
127+
InflatingInputStream inflater(istr, -10);
128+
std::string data2;
129+
inflater >> data2;
130+
assert (data2 == data);
131+
}
132+
133+
116134
void ZLibTest::testGzip1()
117135
{
118136
std::stringstream buffer;
@@ -196,6 +214,7 @@ CppUnit::Test* ZLibTest::suite()
196214
CppUnit_addTest(pSuite, ZLibTest, testDeflate1);
197215
CppUnit_addTest(pSuite, ZLibTest, testDeflate2);
198216
CppUnit_addTest(pSuite, ZLibTest, testDeflate3);
217+
CppUnit_addTest(pSuite, ZLibTest, testDeflate4);
199218
CppUnit_addTest(pSuite, ZLibTest, testGzip1);
200219
CppUnit_addTest(pSuite, ZLibTest, testGzip2);
201220
CppUnit_addTest(pSuite, ZLibTest, testGzip3);

Foundation/testsuite/src/ZLibTest.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ class ZLibTest: public CppUnit::TestCase
4949
void testDeflate1();
5050
void testDeflate2();
5151
void testDeflate3();
52+
void testDeflate4();
5253
void testGzip1();
5354
void testGzip2();
5455
void testGzip3();

NetSSL_OpenSSL/src/SecureSocketImpl.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -231,12 +231,12 @@ void SecureSocketImpl::listen(int backlog)
231231
void SecureSocketImpl::shutdown()
232232
{
233233
if (_pSSL)
234-
{
235-
// Don't shut down the socket more than once.
236-
int shutdownState = SSL_get_shutdown(_pSSL);
237-
bool shutdownSent = (shutdownState & SSL_SENT_SHUTDOWN) == SSL_SENT_SHUTDOWN;
238-
if (!shutdownSent)
239-
{
234+
{
235+
// Don't shut down the socket more than once.
236+
int shutdownState = SSL_get_shutdown(_pSSL);
237+
bool shutdownSent = (shutdownState & SSL_SENT_SHUTDOWN) == SSL_SENT_SHUTDOWN;
238+
if (!shutdownSent)
239+
{
240240
// A proper clean shutdown would require us to
241241
// retry the shutdown if we get a zero return
242242
// value, until SSL_shutdown() returns 1.
@@ -254,7 +254,7 @@ void SecureSocketImpl::shutdown()
254254

255255
void SecureSocketImpl::close()
256256
{
257-
shutdown();
257+
try { shutdown(); } catch (...) { }
258258
_pSocket->close();
259259
}
260260

0 commit comments

Comments
 (0)