Fix leaks in softoken's argument string parsin. r=rrelyea,alexei.

Bug 339173. Modified Files: pk11db.c pk11pars.h


git-svn-id: svn://10.0.0.236/trunk@214116 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
nelson%bolyard.com
2006-10-25 18:47:02 +00:00
parent 6aab452c7b
commit 2f5493ecda
2 changed files with 13 additions and 8 deletions

View File

@@ -74,7 +74,7 @@ CK_RV
secmod_parseTokenParameters(char *param, sftk_token_parameters *parsed)
{
int next;
char *tmp;
char *tmp = NULL;
char *index;
index = secmod_argStrip(param);
@@ -85,12 +85,14 @@ secmod_parseTokenParameters(char *param, sftk_token_parameters *parsed)
SECMOD_HANDLE_STRING_ARG(index,parsed->tokdes,"tokenDescription=",;)
SECMOD_HANDLE_STRING_ARG(index,parsed->slotdes,"slotDescription=",;)
SECMOD_HANDLE_STRING_ARG(index,tmp,"minPWLen=",
if(tmp) { parsed->minPW=atoi(tmp); PORT_Free(tmp); })
if (tmp) { parsed->minPW=atoi(tmp); })
SECMOD_HANDLE_STRING_ARG(index,tmp,"flags=",
if(tmp) { secmod_parseTokenFlags(param,parsed); PORT_Free(tmp); })
if (tmp) { secmod_parseTokenFlags(param,parsed); })
SECMOD_HANDLE_FINAL_ARG(index)
}
return CKR_OK;
}
if (tmp)
PORT_Free(tmp);
return CKR_OK;
}
static void
@@ -143,7 +145,7 @@ CK_RV
secmod_parseParameters(char *param, sftk_parameters *parsed, PRBool isFIPS)
{
int next;
char *tmp;
char *tmp = NULL;
char *index;
char *certPrefix = NULL, *keyPrefix = NULL;
char *tokdes = NULL, *ptokdes = NULL;
@@ -171,11 +173,13 @@ secmod_parseParameters(char *param, sftk_parameters *parsed, PRBool isFIPS)
SECMOD_HANDLE_STRING_ARG(index,minPW,"minPWLen=",;)
SECMOD_HANDLE_STRING_ARG(index,tmp,"flags=",
if(tmp) { secmod_parseFlags(param,parsed); PORT_Free(tmp); })
if (tmp) { secmod_parseFlags(param,parsed); })
SECMOD_HANDLE_STRING_ARG(index,tmp,"tokens=",
if(tmp) { secmod_parseTokens(tmp,parsed); PORT_Free(tmp); })
if (tmp) { secmod_parseTokens(tmp,parsed); })
SECMOD_HANDLE_FINAL_ARG(index)
}
if (tmp)
PORT_Free(tmp);
if (parsed->tokens == NULL) {
int count = isFIPS ? 1 : 2;
int index = count-1;

View File

@@ -92,6 +92,7 @@ static struct secmodargSlotFlagTable secmod_argSlotFlagTable[] = {
#define SECMOD_HANDLE_STRING_ARG(param,target,value,command) \
if (PORT_Strncasecmp(param,value,sizeof(value)-1) == 0) { \
param += sizeof(value)-1; \
if (target) PORT_Free(target); \
target = secmod_argFetchValue(param,&next); \
param += next; \
command ;\