Bug 261506. Handle binary keys up to 128k

This commit is contained in:
Jim Norman 2007-04-05 21:33:47 +00:00
parent 5b7948b5d2
commit 0bfc0a3063
6 changed files with 4256 additions and 4271 deletions

View File

@ -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

View File

@ -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

View File

@ -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"

View File

@ -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

View File

@ -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,19 +3584,17 @@ 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);
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 )
{
tmpBuf = (Byte*)malloc(msgLen);
if( NULL == tmpBuf )
{
retCode = NSSCS_E_SYSTEM_FAILURE;
break;
}
memset(tmpBuf,0,msgLen);
pReq = tmpBuf;
}
else
{
pReq = gpReqBuf;
}
// now allocate the request buffer
if((gpReqBuf = malloc(msgLen)) == NULL)
{
free(gpReplyBuf);
return(NSSCS_E_SYSTEM_FAILURE);
}
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,20 +3728,15 @@ int ipc_WriteBinaryKey
memcpy(pReq,&extID,MSG_DWORD_LEN);
}
if(tmpBuf != NULL)
{
retVal = IPC_WRITE(ssHandle->platHandle,tmpBuf,msgLen);
}
else
{
retVal = IPC_WRITE(ssHandle->platHandle,gpReqBuf, msgLen);
}
if(retVal < 0)
{
//log debug info here
retCode = NSSCS_E_SYSTEM_FAILURE;
break;
}
// write the data
retVal = IPC_WRITE(ssHandle->platHandle,gpReqBuf, msgLen);
if(retVal < 0)
{
//log debug info here
retCode = NSSCS_E_SYSTEM_FAILURE;
break;
}
// Read reply
pReply = gpReplyBuf;
@ -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);
}

View File

@ -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);
}