summaryrefslogtreecommitdiff
path: root/cpp/src/IceSSL/TransceiverI.cpp
diff options
context:
space:
mode:
authorMark Spruiell <mes@zeroc.com>2011-06-02 08:11:53 -0700
committerMark Spruiell <mes@zeroc.com>2011-06-02 08:11:53 -0700
commit661a639570f87ef04a3fc3e30ece5b947e69823e (patch)
tree1c8be61e2d9bc57337e6090c35c1d0a39c05c8b3 /cpp/src/IceSSL/TransceiverI.cpp
parentminor edits to CHANGES (diff)
downloadice-661a639570f87ef04a3fc3e30ece5b947e69823e.tar.bz2
ice-661a639570f87ef04a3fc3e30ece5b947e69823e.tar.xz
ice-661a639570f87ef04a3fc3e30ece5b947e69823e.zip
bug 5098 - access violation in IceSSL transceiver
Diffstat (limited to 'cpp/src/IceSSL/TransceiverI.cpp')
-rw-r--r--cpp/src/IceSSL/TransceiverI.cpp55
1 files changed, 30 insertions, 25 deletions
diff --git a/cpp/src/IceSSL/TransceiverI.cpp b/cpp/src/IceSSL/TransceiverI.cpp
index 52833fdea98..d357049e52e 100644
--- a/cpp/src/IceSSL/TransceiverI.cpp
+++ b/cpp/src/IceSSL/TransceiverI.cpp
@@ -56,7 +56,7 @@ IceSSL::TransceiverI::initialize()
if(_state == StateNeedConnect)
{
_state = StateConnectPending;
- return IceInternal::SocketOperationConnect;
+ return IceInternal::SocketOperationConnect;
}
else if(_state <= StateConnectPending)
{
@@ -64,7 +64,7 @@ IceSSL::TransceiverI::initialize()
IceInternal::doFinishConnect(_fd);
#else
IceInternal::doFinishConnectAsync(_fd, _write);
-#endif
+#endif
_state = StateConnected;
_desc = IceInternal::fdToString(_fd);
}
@@ -103,8 +103,9 @@ IceSSL::TransceiverI::initialize()
if(!BIO_new_bio_pair(&bio, _maxSendPacketSize, &_iocpBio, _maxReceivePacketSize))
{
bio = 0;
+ _iocpBio = 0;
}
-#endif
+#endif
if(!bio)
{
SecurityException ex(__FILE__, __LINE__);
@@ -118,6 +119,7 @@ IceSSL::TransceiverI::initialize()
BIO_free(bio);
#ifdef ICE_USE_IOCP
BIO_free(_iocpBio);
+ _iocpBio = 0;
#endif
SecurityException ex(__FILE__, __LINE__);
ex.reason = "openssl failure";
@@ -176,7 +178,7 @@ IceSSL::TransceiverI::initialize()
return IceInternal::SocketOperationWrite;
}
case SSL_ERROR_SYSCALL:
- {
+ {
if(ret == 0)
{
ConnectionLostException ex(__FILE__, __LINE__);
@@ -184,14 +186,14 @@ IceSSL::TransceiverI::initialize()
throw ex;
}
-#ifndef ICE_USE_IOCP
+#ifndef ICE_USE_IOCP
if(ret == -1)
{
if(IceInternal::interrupted())
{
break;
}
-
+
if(IceInternal::wouldBlock())
{
if(SSL_want_read(_ssl))
@@ -202,10 +204,10 @@ IceSSL::TransceiverI::initialize()
{
return IceInternal::SocketOperationWrite;
}
-
+
break;
}
-
+
if(IceInternal::connectionLost())
{
ConnectionLostException ex(__FILE__, __LINE__);
@@ -248,7 +250,7 @@ IceSSL::TransceiverI::initialize()
struct sockaddr_storage localAddr;
IceInternal::fdToLocalAddress(_fd, localAddr);
-
+
out << "failed to establish ssl connection\n"
<< "local address: " << IceInternal::addrToString(localAddr) << "\n"
<< "remote address: " << IceInternal::addrToString(_connectAddr) << "\n"
@@ -290,7 +292,7 @@ IceSSL::TransceiverI::close()
if(_ssl)
{
int err = SSL_shutdown(_ssl);
-
+
//
// Call it one more time if it returned 0.
//
@@ -479,7 +481,7 @@ IceSSL::TransceiverI::read(IceInternal::Buffer& buf)
#endif
// It's impossible for the packetSize to be more than an Int.
- int packetSize = static_cast<int>(buf.b.end() - buf.i);
+ int packetSize = static_cast<int>(buf.b.end() - buf.i);
while(buf.i != buf.b.end())
{
ERR_clear_error(); // Clear any spurious errors.
@@ -644,7 +646,7 @@ IceSSL::TransceiverI::startWrite(IceInternal::Buffer& buf)
int packetSize = static_cast<int>(_writeBuffer.end() - _writeI);
if(_maxSendPacketSize > 0 && packetSize > _maxSendPacketSize)
- {
+ {
packetSize = _maxSendPacketSize;
}
@@ -748,7 +750,7 @@ IceSSL::TransceiverI::startRead(IceInternal::Buffer& buf)
}
}
-void
+void
IceSSL::TransceiverI::finishRead(IceInternal::Buffer& buf)
{
if(_read.count == SOCKET_ERROR)
@@ -797,7 +799,7 @@ IceSSL::TransceiverI::toString() const
return _desc;
}
-Ice::ConnectionInfoPtr
+Ice::ConnectionInfoPtr
IceSSL::TransceiverI::getInfo() const
{
return getNativeConnectionInfo();
@@ -812,7 +814,7 @@ IceSSL::TransceiverI::checkSendSize(const IceInternal::Buffer& buf, size_t messa
}
}
-IceSSL::TransceiverI::TransceiverI(const InstancePtr& instance, SOCKET fd, const string& host,
+IceSSL::TransceiverI::TransceiverI(const InstancePtr& instance, SOCKET fd, const string& host,
const struct sockaddr_storage& addr) :
IceInternal::NativeInfo(fd),
_instance(instance),
@@ -823,7 +825,8 @@ IceSSL::TransceiverI::TransceiverI(const InstancePtr& instance, SOCKET fd, const
_incoming(false),
_state(StateNeedConnect)
#ifdef ICE_USE_IOCP
- , _read(IceInternal::SocketOperationRead),
+ , _iocpBio(0),
+ _read(IceInternal::SocketOperationRead),
_write(IceInternal::SocketOperationWrite)
#endif
{
@@ -860,7 +863,8 @@ IceSSL::TransceiverI::TransceiverI(const InstancePtr& instance, SOCKET fd, const
_state(StateConnected),
_desc(IceInternal::fdToString(fd))
#ifdef ICE_USE_IOCP
- , _read(IceInternal::SocketOperationRead),
+ , _iocpBio(0),
+ _read(IceInternal::SocketOperationRead),
_write(IceInternal::SocketOperationWrite)
#endif
{
@@ -901,7 +905,7 @@ IceSSL::TransceiverI::getNativeConnectionInfo() const
{
X509_free(cert);
}
-
+
if(chain != 0)
{
for(int i = 0; i < sk_X509_num(chain); ++i)
@@ -914,12 +918,13 @@ IceSSL::TransceiverI::getNativeConnectionInfo() const
info->certs.push_back(certificate->encode());
}
}
-
+
info->cipher = SSL_get_cipher_name(_ssl); // Nothing needs to be free'd.
info->adapterName = _adapterName;
info->incoming = _incoming;
return info;
}
+
#ifdef ICE_USE_IOCP
bool
IceSSL::TransceiverI::receive()
@@ -949,7 +954,7 @@ IceSSL::TransceiverI::receive()
{
continue;
}
-
+
if(IceInternal::noBuffers() && packetSize > 1024)
{
packetSize /= 2;
@@ -960,7 +965,7 @@ IceSSL::TransceiverI::receive()
{
return false;
}
-
+
if(IceInternal::connectionLost())
{
ConnectionLostException ex(__FILE__, __LINE__);
@@ -1002,7 +1007,7 @@ IceSSL::TransceiverI::send()
int packetSize = static_cast<int>(_writeBuffer.end() - _writeI);
if(_maxSendPacketSize > 0 && packetSize > _maxSendPacketSize)
- {
+ {
packetSize = _maxSendPacketSize;
}
@@ -1015,7 +1020,7 @@ IceSSL::TransceiverI::send()
ex.error = 0;
throw ex;
}
-
+
if(ret == SOCKET_ERROR)
{
if(IceInternal::interrupted())
@@ -1033,7 +1038,7 @@ IceSSL::TransceiverI::send()
{
return false;
}
-
+
if(IceInternal::connectionLost())
{
ConnectionLostException ex(__FILE__, __LINE__);
@@ -1047,7 +1052,7 @@ IceSSL::TransceiverI::send()
throw ex;
}
}
-
+
_writeI += ret;
if(packetSize > _writeBuffer.end() - _writeI)
{