syncmlfw/dm/provisioningadapter/src/NSmlDmProvisioningAdapter.cpp
changeset 44 39aa16f3fdc2
parent 24 bf47f3b79154
child 60 eb6690d0d439
--- a/syncmlfw/dm/provisioningadapter/src/NSmlDmProvisioningAdapter.cpp	Wed Jun 23 19:10:17 2010 +0300
+++ b/syncmlfw/dm/provisioningadapter/src/NSmlDmProvisioningAdapter.cpp	Tue Jul 06 15:14:24 2010 +0300
@@ -40,6 +40,8 @@
 #include "NSmlTransportHandler.h"
 
 #include <data_caging_path_literals.hrh>
+#define KMINPORT 0
+#define KMAXPORT 65536
 
 // ============================ MEMBER FUNCTIONS ===============================
 
@@ -184,7 +186,35 @@
 		iAuthSecretLimitIndicator = 0;
 		User::Leave(KErrOverflow);
 	}
-
+	
+	//check for incorrect port
+	//Only port address between 1 to 65536 is allowed. 
+	if( iProfiles[aItem]->iPort )
+		{
+			const TDesC& port = iProfiles[aItem]->iPort->Des();
+			TInt len = port.Length();
+			if(len > 0)
+			{
+        HBufC* bufPort = port.AllocL();
+        TLex aLex(*bufPort);
+        TInt portNum ;
+        TInt err = aLex.Val(portNum);
+        if(bufPort)
+        {
+          delete bufPort;
+          bufPort = NULL;
+        }
+	    if(err != KErrNone)
+	    {
+          User::Leave(KErrGeneral);
+	    }
+	    if(!((portNum > KMINPORT) && (portNum < KMAXPORT)))
+	    {
+	      User::Leave(KErrGeneral);       
+	    }
+		}
+	}
+	
 	TPckgBuf<TUint32> uid;
 	
 	RSyncMLDevManProfile profile,ProfileToSearch;
@@ -289,7 +319,7 @@
 
 		connection.SetPropertyL( KNSmlIAPId, *iapBuf );
 		
-		CleanupStack::PopAndDestroy( 2 ); //cmmanager,cm	
+		CleanupStack::PopAndDestroy( 3 ); //cmmanager,cm, iapBuf
 		}
 		
 	if( iProfiles[aItem]->iHostAddress )