Revision: 201036 RCL_3
authorDremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
Wed, 15 Sep 2010 13:53:10 +0300
branchRCL_3
changeset 67 bb2423252ea3
parent 63 425d8f4f7fa5
child 75 c1029e558ef5
Revision: 201036 Kit: 201036
networkprotocols/iphook/inhook6/src/in_pkt.cpp
networksecurity/tls/protocol/applicationdata.cpp
networksecurity/tls/protocol/handshakereceiveevents.cpp
networksecurity/tls/protocol/recordprotocolevents.cpp
networksecurity/tls/protocol/tlsconnection.cpp
networksecurity/tls/protocol/tlshandshake.cpp
networksecurity/tlsprovider/source/tlsprovider/CTlsProvider.cpp
networksecurity/tlsprovider/source/tlsprovider/Ctlsbrowsetoken.cpp
networksecurity/tlsprovider/source/tlsprovider/tlsprovinterface.cpp
--- a/networkprotocols/iphook/inhook6/src/in_pkt.cpp	Wed Sep 15 00:18:51 2010 +0300
+++ b/networkprotocols/iphook/inhook6/src/in_pkt.cpp	Wed Sep 15 13:53:10 2010 +0300
@@ -85,7 +85,7 @@
 			if (len < aMin)
 				return NULL;
 			iLength = len;
-			return p->Buffer() + offset;
+			return p->Buffer() ? (p->Buffer()+ offset): NULL;
 			}
 		// The requested alignment value is not
 		// satisfied!
--- a/networksecurity/tls/protocol/applicationdata.cpp	Wed Sep 15 00:18:51 2010 +0300
+++ b/networksecurity/tls/protocol/applicationdata.cpp	Wed Sep 15 13:53:10 2010 +0300
@@ -35,7 +35,7 @@
   	LOG(Log::Printf(_L("self %x - %x"), self, (TUint)self + sizeof( CSendAppData ));)
 	CleanupStack::PushL( self );
 	self->ConstructL( aRecordComposer );
-	CleanupStack::Pop();
+	CleanupStack::Pop(self);
 	return self;
 }
 
@@ -167,7 +167,7 @@
   	LOG(Log::Printf(_L("self %x - %x"), self, (TUint)self + sizeof( CRecvAppData ));)
 	CleanupStack::PushL( self );
 	self->ConstructL( aTlsConnection );
-	CleanupStack::Pop();
+	CleanupStack::Pop(self);
 	return self;
 }
 
--- a/networksecurity/tls/protocol/handshakereceiveevents.cpp	Wed Sep 15 00:18:51 2010 +0300
+++ b/networksecurity/tls/protocol/handshakereceiveevents.cpp	Wed Sep 15 13:53:10 2010 +0300
@@ -448,7 +448,7 @@
       HBufC8* buf = listPtr.AllocL();
    	CleanupStack::PushL(buf);
 		User::LeaveIfError(cryptoAttributes.iDistinguishedCANames.Append(buf) );
-   	CleanupStack::Pop();
+   	CleanupStack::Pop(buf);
 		listNode = listNode->Next();
 	}
    iTlsProvider->Attributes()->iClientAuthenticate = ETrue;
--- a/networksecurity/tls/protocol/recordprotocolevents.cpp	Wed Sep 15 00:18:51 2010 +0300
+++ b/networksecurity/tls/protocol/recordprotocolevents.cpp	Wed Sep 15 13:53:10 2010 +0300
@@ -234,7 +234,12 @@
 	    {
 		iActiveTlsSession->CancelRequest();
 		}
-	ReConstructL();
+
+    TRAPD(ret, ReConstructL());
+    if ( ret != KErrNone )
+        {
+        LOG(Log::Printf(_L("ReConstructL() returned the error %d"), ret);)
+        }
 }
 
 void CRecordParser::DispatchData()
--- a/networksecurity/tls/protocol/tlsconnection.cpp	Wed Sep 15 00:18:51 2010 +0300
+++ b/networksecurity/tls/protocol/tlsconnection.cpp	Wed Sep 15 13:53:10 2010 +0300
@@ -55,7 +55,7 @@
 
 	CleanupStack::PushL(self);
 	self->ConstructL(aSocket, aProtocol);
-	CleanupStack::Pop();
+	CleanupStack::Pop(self);
 	return self;
 }
 
@@ -80,7 +80,7 @@
 
 	CleanupStack::PushL(self);
 	self->ConstructL(aSocket, aProtocol);
-	CleanupStack::Pop();
+	CleanupStack::Pop(self);
 	return self;
 }
 
@@ -1244,12 +1244,19 @@
 		   return EFalse;
 	      }
       else
-         {//delete data path in case it's re-negotiation what's failed
-         delete iSendAppData;
-         iSendAppData = NULL;
-         delete iRecvAppData;
-         iRecvAppData = NULL;
-         ResetCryptoAttributes();
+         {
+		 //We came here since tls handshake failed for some reasons.
+         //Attempting to delete the application data state machines here,
+         //leads to sending incorrect status to the caller application.
+         //Allow the cleanup of handshake statemachine to continue here.
+         //Let the application data state machines be cleaned up by the 
+         //tlsconnection desctructor function.
+         
+         //delete iSendAppData;
+         //iSendAppData = NULL;
+         //delete iRecvAppData;
+         //iRecvAppData = NULL;
+         //ResetCryptoAttributes();
          }
    }
    else
@@ -1363,7 +1370,7 @@
 	else
 	{	
 		iRecordComposer->SetUserData( (TDesC8*)&aDesc );
-   	iRecordComposer->ResetCurrentPos();
+		iRecordComposer->ResetCurrentPos();
 		iSendAppData->Start( &aStatus, this );
 	}
 	
--- a/networksecurity/tls/protocol/tlshandshake.cpp	Wed Sep 15 00:18:51 2010 +0300
+++ b/networksecurity/tls/protocol/tlshandshake.cpp	Wed Sep 15 13:53:10 2010 +0300
@@ -55,7 +55,7 @@
   	LOG(Log::Printf(_L("self %x - %x"), self, (TUint)self + sizeof( CHandshake ));)
 	CleanupStack::PushL(self);
 	self->ConstructL(aTlsConnection);
-	CleanupStack::Pop();
+	CleanupStack::Pop(self);
 	return self;
 }
 
--- a/networksecurity/tlsprovider/source/tlsprovider/CTlsProvider.cpp	Wed Sep 15 00:18:51 2010 +0300
+++ b/networksecurity/tlsprovider/source/tlsprovider/CTlsProvider.cpp	Wed Sep 15 13:53:10 2010 +0300
@@ -140,7 +140,7 @@
 	CTlsCryptoAttributes* tPtr = new (ELeave)CTlsCryptoAttributes;
 	CleanupStack::PushL(tPtr);
 	tPtr->iPublicKeyParams = new (ELeave)CTLSPublicKeyParams;
-	CleanupStack::Pop();
+	CleanupStack::Pop(tPtr);
 	return tPtr;
 	}
 
@@ -1317,9 +1317,10 @@
 	
 	case EGetSessionInterface:
 		{
-		iPtrTokenSearch->CancelRequest();
+		if (iPtrTokenSearch)
+		    iPtrTokenSearch->CancelRequest();
+		}
 		break;
-		}
 	case EGetCiphers:
 		{
 		if(iListAllTokensAndTypes[iCurrentTokentype].iProviderInterface)
@@ -1371,7 +1372,8 @@
 #ifdef _USESECDLGSV_
 		iDialogServ.Cancel();
 #else
-		iSecurityDialog->Cancel();
+		if (iSecurityDialog)
+		    iSecurityDialog->Cancel();
 #endif
 		}
 		break;
--- a/networksecurity/tlsprovider/source/tlsprovider/Ctlsbrowsetoken.cpp	Wed Sep 15 00:18:51 2010 +0300
+++ b/networksecurity/tlsprovider/source/tlsprovider/Ctlsbrowsetoken.cpp	Wed Sep 15 13:53:10 2010 +0300
@@ -183,7 +183,10 @@
       if ( !tempObj || iListAllTokensAndTypes->Append(*tempObj) != KErrNone )
          {
    		delete tempObj;
-         iTokenHandle->Release();
+   		if (iTokenHandle)
+   		    {
+   		    iTokenHandle->Release();
+   		    }
          iTokenHandle = NULL;
          User::Leave( KErrNoMemory );
          }
@@ -192,7 +195,10 @@
       Tokens.iTokenInfo = new CTokenInfo;
       if ( !Tokens.iTokenInfo  )
          {
-         iTokenHandle->Release();
+          if (iTokenHandle)
+              {
+              iTokenHandle->Release();
+              }
          iTokenHandle = NULL;
          User::Leave( KErrNoMemory );
          }
@@ -307,24 +313,39 @@
 	switch (iCurrentState)
 		{
 	case EGetTokenList:
-		iPtrTokenType->CancelList();
+        {
+	    if (iPtrTokenType)
+	        iPtrTokenType->CancelList();
+        }
 		break;
 		
 	case EOpenToken:
-		iPtrTokenType->CancelOpenToken();
+	    {
+	    if (iPtrTokenType)
+	        iPtrTokenType->CancelOpenToken();
+	    }
 		break;
 		
 	case EGetProviderInterface:
-		iTokenHandle->CancelGetInterface();
+	    {
+	    if (iTokenHandle)
+	        iTokenHandle->CancelGetInterface();
+	    }
 		break;
 	
 	case EGetSessionInterface:
-		(iTokenProvider->Token()).CancelGetInterface();
+	    {
+	    if (iTokenProvider)
+	        (iTokenProvider->Token()).CancelGetInterface();
+	    }
 		break;		
 
 	case EGetCiphers:
-		MTLSTokenProvider* provider = static_cast<MTLSTokenProvider*>(iTokenInterface);
-		provider->CancelCryptoCapabilities();
+	    if (iTokenInterface)
+	        {
+	        MTLSTokenProvider* provider = static_cast<MTLSTokenProvider*>(iTokenInterface);
+	        provider->CancelCryptoCapabilities();
+	        }
 		break;
 
 		}
@@ -335,7 +356,7 @@
 
 CTlsBrowseToken::~CTlsBrowseToken()
 	{
-	if(iPtrTokenType)
+	if (iPtrTokenType)
 		{
 		iPtrTokenType->Release();
 		}
--- a/networksecurity/tlsprovider/source/tlsprovider/tlsprovinterface.cpp	Wed Sep 15 00:18:51 2010 +0300
+++ b/networksecurity/tlsprovider/source/tlsprovider/tlsprovinterface.cpp	Wed Sep 15 13:53:10 2010 +0300
@@ -251,7 +251,8 @@
 */
 EXPORT_C void CTLSProvider::CancelRequest()
 	{
-	iTlsProviderImpl->CancelRequest();
+    if (iTlsProviderImpl)
+        iTlsProviderImpl->CancelRequest();
 	}
 
 
@@ -667,11 +668,13 @@
 */
 EXPORT_C void CTLSSession::CancelRequest()
 	{
-	iTlsSessionImpl->CancelRequest();
+    if (iTlsSessionImpl)
+        iTlsSessionImpl->CancelRequest();
 	}
 
 EXPORT_C CTLSSession::~CTLSSession()
 	{
 	delete iTlsSessionImpl;
+	iTlsSessionImpl = NULL;
 	}