Bug 261506. Handle binary keys up to 128k
This commit is contained in:
		| @@ -1,3 +1,8 @@ | ||||
| ------------------------------------------------------------------- | ||||
| Thu Apr  5 15:30:41 MDT 2007 - jnorman@novell.com | ||||
|  | ||||
| - Bug 261506. Support binary keys up to 128k  | ||||
|  | ||||
| ------------------------------------------------------------------- | ||||
| Mon Apr  2 14:19:58 MDT 2007 - jnorman@novell.com | ||||
|  | ||||
|   | ||||
| @@ -170,6 +170,7 @@ static SS_UTF8_T SSCS_LOCAL_REMOTE_KEY_CHAIN_ID[] = 	{"SSCS_LOCAL_REMOTE_KEY_CHA | ||||
| #define	NSSCS_MID_SECRET_BUF_LEN		32768	//* (4K-128)to match server | ||||
| #define	NSSCS_MAX_SECRET_BUF_LEN		60416	//* (59K)to match server | ||||
| #define	NSSCS_MAX_PWORD_HINT_LEN		128		//* maximum hint (bytes) | ||||
| #define	NSSCS_MAX_BINARY_VALUE_LEN		128*1024	//* Max for binary values (bytes) | ||||
|  | ||||
|  | ||||
| #define	NSSCS_MAX_KEYCHAIN_ID_LEN		256		//* in bytes including NULL | ||||
|   | ||||
| @@ -34,6 +34,7 @@ typedef uint8_t Byte; | ||||
| // Used for global buffers. | ||||
| #define	MIN_REQUEST_BUF_LEN		32*1024 | ||||
| #define	MIN_REPLY_BUF_LEN		32*1024 | ||||
| #define MAX_BINARY_KEY_LEN		256*1024 | ||||
|  | ||||
| #ifdef SSCS_LINUX_PLAT_F | ||||
| #include "sscs_unx_ipc_client.h" | ||||
|   | ||||
| @@ -178,6 +178,7 @@ int ipc_unx_read(int fd, Byte *pData, int bytes) | ||||
|  | ||||
|     int bytesToRead = 0; // Keep track of number of bytes to read | ||||
|     int bytesRead = 0; // Number of bytes read | ||||
|     int totalBytesRead = 0; | ||||
|     int retVal = 0; | ||||
|  | ||||
|     for(bytesToRead = bytes; bytesToRead;) | ||||
| @@ -194,9 +195,10 @@ int ipc_unx_read(int fd, Byte *pData, int bytes) | ||||
| 	        } | ||||
|         	bytesToRead -= bytesRead; | ||||
| 	        pData += bytesRead; | ||||
| 		totalBytesRead += bytesRead; | ||||
| 		} | ||||
|     } | ||||
|     return bytesRead; | ||||
|     return totalBytesRead; | ||||
| } | ||||
| //#endif | ||||
|  | ||||
|   | ||||
| @@ -3078,14 +3078,14 @@ int32_t ipc_ReadBinaryKey | ||||
| 		return(NSSCS_E_SYSTEM_FAILURE);		 | ||||
| 	} | ||||
|  | ||||
| 	if((gpReplyBuf = malloc(MIN_REPLY_BUF_LEN)) == NULL) | ||||
| 	if((gpReplyBuf = malloc(MAX_BINARY_KEY_LEN + 1024)) == NULL) | ||||
| 	{ | ||||
| 		free(gpReqBuf); | ||||
| 		return(NSSCS_E_SYSTEM_FAILURE);		 | ||||
| 	} | ||||
|  | ||||
| 	memset(gpReqBuf, 0, MIN_REQUEST_BUF_LEN); | ||||
| 	memset(gpReplyBuf, 0, MIN_REPLY_BUF_LEN); | ||||
| 	memset(gpReplyBuf, 0, MAX_BINARY_KEY_LEN + 1024); | ||||
|  | ||||
|   do | ||||
|   { | ||||
| @@ -3584,18 +3584,16 @@ int ipc_WriteBinaryKey | ||||
| 	Byte *gpReplyBuf = NULL; | ||||
| 	Byte *pReq = NULL, *pReply = NULL; | ||||
|  | ||||
| 	if((gpReqBuf = malloc(MIN_REQUEST_BUF_LEN)) == NULL) | ||||
| 	if (valLen > MAX_BINARY_KEY_LEN) | ||||
| 	{ | ||||
| 		return(NSSCS_E_SYSTEM_FAILURE);		 | ||||
| 	} | ||||
|  | ||||
| 	if((gpReplyBuf = malloc(MIN_REPLY_BUF_LEN)) == NULL) | ||||
| 	{ | ||||
| 		free(gpReqBuf); | ||||
| 		return(NSSCS_E_SYSTEM_FAILURE);		 | ||||
| 	} | ||||
|  | ||||
|   memset(gpReqBuf,0, MIN_REQUEST_BUF_LEN); | ||||
| 	memset(gpReplyBuf,0, MIN_REPLY_BUF_LEN); | ||||
|  | ||||
|   do | ||||
| @@ -3659,29 +3657,17 @@ int ipc_WriteBinaryKey | ||||
| 			msgLen += MSG_DWORD_LEN; | ||||
| 		} | ||||
|  | ||||
|       if( msgLen > MIN_REQUEST_BUF_LEN ) | ||||
| 		// now allocate the request buffer | ||||
| 		if((gpReqBuf = malloc(msgLen)) == NULL) | ||||
| 		{ | ||||
|           tmpBuf = (Byte*)malloc(msgLen); | ||||
|           if( NULL == tmpBuf ) | ||||
|           { | ||||
|               retCode = NSSCS_E_SYSTEM_FAILURE; | ||||
|               break; | ||||
| 			free(gpReplyBuf); | ||||
| 			return(NSSCS_E_SYSTEM_FAILURE);		 | ||||
| 		} | ||||
|           memset(tmpBuf,0,msgLen); | ||||
|           pReq = tmpBuf; | ||||
|       } | ||||
|       else | ||||
|       { | ||||
|  | ||||
| 		memset(gpReqBuf, 0, msgLen); | ||||
| 		pReq = gpReqBuf; | ||||
|       }         | ||||
|  | ||||
| 	 | ||||
|  	    if(msgLen >= MIN_REQUEST_BUF_LEN) | ||||
|  	    { | ||||
|  	        retCode = NSSCS_E_SYSTEM_FAILURE; | ||||
|  	        break; | ||||
|  	    } | ||||
|  | ||||
| 		// marshall the request | ||||
| 		msgid = REQ_WRITE_BINARY_KEY_MSGID;		 | ||||
| 	 | ||||
|       memcpy(pReq, &msgid, MSGID_LEN); | ||||
| @@ -3742,14 +3728,9 @@ int ipc_WriteBinaryKey | ||||
|           memcpy(pReq,&extID,MSG_DWORD_LEN); | ||||
|       } | ||||
|  | ||||
|       if(tmpBuf != NULL) | ||||
|       { | ||||
|           retVal = IPC_WRITE(ssHandle->platHandle,tmpBuf,msgLen); | ||||
|       } | ||||
|       else | ||||
|       { | ||||
|  | ||||
| 		// write the data | ||||
| 		retVal = IPC_WRITE(ssHandle->platHandle,gpReqBuf, msgLen);       | ||||
|       } | ||||
| 		if(retVal < 0) | ||||
| 		{ | ||||
| 			//log debug info here | ||||
| @@ -3777,15 +3758,10 @@ int ipc_WriteBinaryKey | ||||
|   } | ||||
|   while(0); | ||||
|  | ||||
|   if( tmpBuf != NULL ) | ||||
|   { | ||||
|       free(tmpBuf); | ||||
|       tmpBuf = NULL; | ||||
|   } | ||||
|  | ||||
| 	if(gpReqBuf) | ||||
| 	{ | ||||
| 		memset(gpReqBuf, 0, MIN_REQUEST_BUF_LEN); | ||||
| 		memset(gpReqBuf, 0, msgLen); | ||||
| 		free(gpReqBuf); | ||||
| 	} | ||||
| 	 | ||||
|   | ||||
| @@ -1747,7 +1747,7 @@ miCASAWriteBinaryKey | ||||
| 		return(NSSCS_E_BUFFER_LEN);		 | ||||
| 	} | ||||
|  | ||||
| 	if ((keyLen > NSSCS_MAX_SECRET_ID_LEN/4) || (*valLen > NSSCS_MAX_SECRET_BUF_LEN/4)) | ||||
| 	if ((keyLen > NSSCS_MAX_SECRET_ID_LEN/4) || (*valLen > NSSCS_MAX_BINARY_VALUE_LEN)) | ||||
| 	{ | ||||
| 		return(NSSCS_E_BUFFER_LEN); | ||||
| 	} | ||||
|   | ||||
		Reference in New Issue
	
	Block a user