persistentstorage/sql/SRC/Server/SqlSrvSession.cpp
branchRCL_3
changeset 10 31a8f755b7fe
parent 9 667e88a979d7
child 11 211563e4b919
equal deleted inserted replaced
9:667e88a979d7 10:31a8f755b7fe
   509 Arg 0: [in]  database file name length in 16-bit characters
   509 Arg 0: [in]  database file name length in 16-bit characters
   510 Arg 1: [in]  database file name
   510 Arg 1: [in]  database file name
   511 Arg 2: [in]  PPPPCCCC, where PPPP is the security policy length, CCCC is the config string length.
   511 Arg 2: [in]  PPPPCCCC, where PPPP is the security policy length, CCCC is the config string length.
   512 Arg 3: [in]  security policies buffer | config string
   512 Arg 3: [in]  security policies buffer | config string
   513 
   513 
   514 @leave KErrArgument If config string length or security policy length is invalid (negative length or too big length)
       
   515 @panic SqlDb 1 Client panic. iDatabase is not NULL (it has been created already)
   514 @panic SqlDb 1 Client panic. iDatabase is not NULL (it has been created already)
       
   515 @panic SqlDb 4 Client panic. Negative or too big config string length
       
   516 @panic SqlDb 4 Client panic. Negative security policy length, or zero length if the request is to create a secure database 
   516 */
   517 */
   517 void CSqlSrvSession::DbCreateObjectL(const RMessage2& aMessage, TSqlSrvFunction aFunction)
   518 void CSqlSrvSession::DbCreateObjectL(const RMessage2& aMessage, TSqlSrvFunction aFunction)
   518 	{
   519 	{
   519 	__SQLPANIC_CLIENT(!iDatabase, aMessage, ESqlPanicObjExists);
   520 	__SQLPANIC_CLIENT(!iDatabase, aMessage, ESqlPanicObjExists);
   520 	const TInt KSecurityPolicyLen = (aMessage.Int2() & 0x7fff0000) >> 16;
   521 	const TInt KSecurityPolicyLen = (aMessage.Int2() & 0x7fff0000) >> 16;
       
   522     //If the security policy length is negative then this is a programming error.
       
   523     __SQLPANIC_CLIENT(KSecurityPolicyLen >= 0, aMessage, ESqlPanicBadArgument);
   521 	const TInt KConfigStringLen = aMessage.Int2() & 0xffff;
   524 	const TInt KConfigStringLen = aMessage.Int2() & 0xffff;
   522 	if(KSecurityPolicyLen < 0 || (TUint)KConfigStringLen > KSqlSrvMaxConfigStrLen)
   525 	//If KConfigStringLen is invalid then this is a programming error. 
   523 		{
   526 	//If the client sends a too big config string - this is handled in the client side session.
   524 		__SQLLEAVE(KErrArgument);	
   527     __SQLPANIC_CLIENT((TUint)KConfigStringLen <= KSqlSrvMaxConfigStrLen, aMessage, ESqlPanicBadArgument);
   525 		}
       
   526 	RBuf8 securityAndConfigBuf;
   528 	RBuf8 securityAndConfigBuf;
   527 	CleanupClosePushL(securityAndConfigBuf);
   529 	CleanupClosePushL(securityAndConfigBuf);
   528 	if((KSecurityPolicyLen + KConfigStringLen) > 0)
   530 	if((KSecurityPolicyLen + KConfigStringLen) > 0)
   529 	    {
   531 	    {
   530 	    securityAndConfigBuf.CreateL(KSecurityPolicyLen + KConfigStringLen);
   532 	    securityAndConfigBuf.CreateL(KSecurityPolicyLen + KConfigStringLen);
   548 				}
   550 				}
   549 			iDatabase = CSqlSrvDatabase::CreateL(fileData);
   551 			iDatabase = CSqlSrvDatabase::CreateL(fileData);
   550 			break;
   552 			break;
   551 		case ESqlSrvDbCreateSecure:
   553 		case ESqlSrvDbCreateSecure:
   552 			{
   554 			{
   553 			if(!fileData.IsSecureFileNameFmt() || KSecurityPolicyLen == 0)
   555 		    __SQLPANIC_CLIENT(KSecurityPolicyLen > 0, aMessage, ESqlPanicBadArgument);
       
   556 			if(!fileData.IsSecureFileNameFmt())
   554 				{
   557 				{
   555 				__SQLLEAVE(KErrArgument);	
   558 				__SQLLEAVE(KErrArgument);	
   556 				}
   559 				}
   557 			//The caller can create a secure database which secure UID matches his secure UID.
   560 			//The caller can create a secure database which secure UID matches his secure UID.
   558 			if(fileData.SecureUid() != aMessage.SecureId())
   561 			if(fileData.SecureUid() != aMessage.SecureId())
  1522 TInt CSqlSrvSession::NewOutputStreamL(const RMessage2& aMessage, MStreamBuf* aStreamBuf)
  1525 TInt CSqlSrvSession::NewOutputStreamL(const RMessage2& aMessage, MStreamBuf* aStreamBuf)
  1523 	{
  1526 	{
  1524 	aStreamBuf->PushL();
  1527 	aStreamBuf->PushL();
  1525 	iIpcStreams.AllocL();
  1528 	iIpcStreams.AllocL();
  1526 	TInt size = aStreamBuf->SizeL();
  1529 	TInt size = aStreamBuf->SizeL();
       
  1530 	__SQLASSERT(size >= 0, ESqlPanicInternalError);
  1527 	TPckgBuf<TIpcStreamBuf> ipcBuf;
  1531 	TPckgBuf<TIpcStreamBuf> ipcBuf;
  1528 	if(size > 0)						// read the first buffer-full
  1532     // read the first buffer-full
  1529 		{
  1533     TInt len = Min(size, KIpcBufSize);
  1530 		TInt len = Min(size, KIpcBufSize);
  1534     aStreamBuf->ReadL(ipcBuf().iData, len);
  1531 		aStreamBuf->ReadL(ipcBuf().iData, len);
       
  1532 		}
       
  1533 	TInt handle = 0;
  1535 	TInt handle = 0;
  1534 	if(size < 0 || size > KIpcBufSize)
  1536 	if(size > KIpcBufSize)
  1535 		{								// create the stream object
  1537 		{								// create the stream object
  1536 		HIpcStream* ipcStream = new (ELeave) HIpcStream(aStreamBuf, KIpcBufSize);
  1538 		HIpcStream* ipcStream = new (ELeave) HIpcStream(aStreamBuf, KIpcBufSize);
  1537 		handle = iIpcStreams.Add(ipcStream);
  1539 		handle = iIpcStreams.Add(ipcStream);
  1538 		__SQLPANIC_CLIENT(handle > 0, aMessage, ESqlPanicBadHandle);
  1540 		__SQLPANIC_CLIENT(handle > 0, aMessage, ESqlPanicBadHandle);
  1539 		CleanupStack::Pop(aStreamBuf);
  1541 		CleanupStack::Pop(aStreamBuf);
  1540 		}
  1542 		}
  1541 	else								// no more data to send
  1543 	else								// no more data to send
  1542 		{
  1544 		{
  1543 		CleanupStack::PopAndDestroy(aStreamBuf);
  1545 		CleanupStack::PopAndDestroy(aStreamBuf);
  1544 		}
  1546 		}
  1545 	if(size >= 0)
  1547     ipcBuf().iExt = size;
  1546 		{
  1548     aMessage.WriteL(2, ipcBuf);
  1547 		ipcBuf().iExt = size;
  1549     SQLPROFILER_REPORT_IPC(ESqlIpcWrite, size);
  1548 		aMessage.WriteL(2, ipcBuf);
       
  1549 		SQLPROFILER_REPORT_IPC(ESqlIpcWrite, size);
       
  1550 		}
       
  1551 	return handle;
  1550 	return handle;
  1552 	}
  1551 	}
  1553 
  1552 
  1554 /**
  1553 /**
  1555 Reads a 8-bit string with "aByteLen" bytes length, which is in "aArgNum" argument of aMessage.
  1554 Reads a 8-bit string with "aByteLen" bytes length, which is in "aArgNum" argument of aMessage.