diff --git a/CASA/include/cardselector.h b/CASA/include/cardselector.h index 7e72d5b3..5efc38fc 100644 --- a/CASA/include/cardselector.h +++ b/CASA/include/cardselector.h @@ -23,6 +23,7 @@ #include "micasa_types.h" #include "micasa_mgmd.h" -int launchSelector( void *secretHandle, +int launchSelector( char *pSecretID, + void *secretHandle, SSCS_BASIC_CREDENTIAL *basicCred); diff --git a/CASA/micasadk/cardselector.c b/CASA/micasadk/cardselector.c index 23f27fd2..f98dd6f5 100644 --- a/CASA/micasadk/cardselector.c +++ b/CASA/micasadk/cardselector.c @@ -259,7 +259,8 @@ int getLine(char *line, int max, FILE *fp) /**************************************************************************** Desc: ****************************************************************************/ -int launchSelector(void *secretHandle, +int launchSelector(char* pSecretID, + void *secretHandle, SSCS_BASIC_CREDENTIAL *basicCred) { @@ -274,6 +275,8 @@ int launchSelector(void *secretHandle, int32_t argCount = 0; void *pArgs[MAXARGS] = {0}; + void *pAppliesTo; + int32_t claimCount = 0; void *pKeys[MAXCLAIMS] = {0}; void *pClaims[MAXCLAIMS] = {0}; @@ -291,11 +294,13 @@ int launchSelector(void *secretHandle, const char line[256]; - char claimURI[256]; - char claimvalue[256]; + char claimURI[256] = {0}; + char claimvalue[256] = {0}; int indexToDigitalMeApp = 0; + printf("launchSelector method called\r\n"); + if (findDigitalMe(&indexToDigitalMeApp) == 0) { // Get a temp name for the token file @@ -326,6 +331,9 @@ int launchSelector(void *secretHandle, return NSSCS_E_INVALID_SECRET_ID; } + memset(pKey, 0, NSSCS_MAX_SECRET_ID_LEN); + memset(pValue, 0, NSSCS_MAX_SECRET_BUF_LEN); + // read the mapped pClaims // enumerate this list looking for username and password if(!(rcode = miCASA_GetNextSHSEntry(1, secretHandle, &kLen, pKey, &vLen, pValue))) @@ -337,16 +345,13 @@ int launchSelector(void *secretHandle, break; } - // Save of key anc claim mapping - if (argCount < MAXCLAIMS) + // Save of key and claim mapping + if (claimCount < MAXCLAIMS) { - pTempPtr = malloc(sscs_strlen(pValue)); - sscs_strncpy(pTempPtr, pKey, sscs_strlen(pKey)); - pKeys[claimCount] = pTempPtr; - - printf("URI: %s\r\n", pValue); - pTempPtr = malloc(sscs_strlen(pValue)); - sscs_strncpy(pTempPtr, pValue, sscs_strlen(pValue)); + printf("URI: %s (%d)\r\n", pValue, vLen); + pTempPtr = malloc(vLen); + memset(pTempPtr, 0, vLen); + sscs_strncpy(pTempPtr, pValue, vLen); pClaims[claimCount++] = pTempPtr; claimStrLen += sscs_strlen(pValue); } @@ -360,20 +365,29 @@ int launchSelector(void *secretHandle, while(rcode == NSSCS_SUCCESS); } - printf("Launch selector\r\n"); + printf("Launching selector\r\n"); // Set up args pArgs[argCount++] = dmPaths[indexToDigitalMeApp]; pArgs[argCount++] = &DM_GET_TOKEN_ARG_STR; //pArgs[argCount++] = &DM_RECIPIENT_ARG_STR; + pAppliesTo = malloc(strlen(pSecretID) + 20); + memset(pAppliesTo, 0, strlen(pSecretID) + 20); + sscs_strcpy(pAppliesTo, &DM_RECIPIENT_ARG_STR); + sscs_strcat(pAppliesTo, "=\""); + sscs_strcat(pAppliesTo, pSecretID); + sscs_strcat(pAppliesTo, "\""); + //pArgs[argCount++] = pAppliesTo; + // Setup claims arg - pClaimsStr = malloc(claimStrLen + 10); + pClaimsStr = malloc(claimStrLen + 20); + memset(pClaimsStr, 0, claimStrLen + 20); sscs_strcpy(pClaimsStr, &DM_REQUIRED_CLAIMS_ARG_STR); sscs_strcat(pClaimsStr, "=\""); - for (i = 0; iid, secretHandle, basicCred); if (rcode == 0) { return rcode;