Пример #1
0
VOID
VMCAFreeStringW(
    RP_PWSTR pszString
    )
{
    VMCAFreeMemory(pszString);
}
Пример #2
0
DWORD
VMCAAllocateMemory(
    DWORD dwSize,
    PVOID * ppMemory
    )
{
    DWORD dwError = 0;
    void* pMemory = NULL;

    if (!ppMemory || !dwSize)
    {
        dwError = ERROR_INVALID_PARAMETER;
        BAIL_ON_ERROR(dwError);
    }

    pMemory = calloc(1, dwSize);
    if (!pMemory)
    {
        dwError = -2; //ERROR_NO_MEMORY;
        BAIL_ON_ERROR(dwError);
    }

cleanup:
    *ppMemory = pMemory;

    return dwError;

error:
    VMCAFreeMemory(pMemory);
    pMemory = NULL;

    goto cleanup;
}
Пример #3
0
VOID
VMCAFreeStringA(
    RP_PSTR pszString
    )
{
    VMCAFreeMemory(pszString);
}
Пример #4
0
static
VOID
VMCASrvFreeDirSyncParams(
    PVMCA_DIR_SYNC_PARAMS pSyncInfo
    )
{
    if (pSyncInfo->pMutex)
    {
        pthread_mutex_destroy(&pSyncInfo->mutex);
        pSyncInfo->pMutex = NULL;
    }
    VMCAFreeMemory(pSyncInfo);
}
Пример #5
0
VOID
VMCALdapClose(
    PVMCA_LDAP_CONTEXT pContext
    )
{
    if (pContext != NULL)
    {
        if (pContext->pConnection != NULL)
        {
            ldap_unbind_ext(pContext->pConnection, NULL, NULL);
        }
        VMCAFreeMemory(pContext);
    }
}
Пример #6
0
DWORD
ConvertAnsitoUnicodeString(
    PCSTR pszSrc,
    PWSTR* ppwszDst
    )
{
    DWORD dwError = 0;
#ifdef _WIN32
	PSTR   pszNewString = NULL;
#endif

    if (!pszSrc || !ppwszDst)
    {
        dwError = ERROR_INVALID_PARAMETER;
    }
    else
    {
#ifdef _WIN32
		// allocate space for new string then pass addr to output
		// double the original PSTR size for WPSTR
		ULONG srcLen =  (ULONG)strlen(pszSrc)+1;
		ULONG destLen = (srcLen+1)*2;
		dwError = VMCAAllocateMemory((DWORD) destLen, (PVOID*)&pszNewString);
		BAIL_ON_ERROR(dwError);

		if (0 == MultiByteToWideChar(CP_ACP, 0, pszSrc, -1, (LPWSTR)pszNewString, destLen))
		{
			dwError = GetLastError();
			BAIL_ON_ERROR(dwError);
		}
		*ppwszDst = (LPWSTR)pszNewString;
cleanup:
	return dwError;

error:
	VMCAFreeMemory(pszNewString);
	goto cleanup;
#else
        dwError = LwNtStatusToWin32Error(
                        LwRtlWC16StringAllocateFromCString(ppwszDst, pszSrc));
#endif
    }
	return dwError;
}
Пример #7
0
DWORD
ConvertUnicodetoAnsiString(
    PCWSTR pwszSrc,
    PSTR*  ppszDst
    )
{
    DWORD dwError = 0;
#ifdef _WIN32
	PSTR   pszNewString = NULL;
#endif

    if (!pwszSrc || !ppszDst)
    {
        dwError = ERROR_INVALID_PARAMETER;
    }
    else
    {
#ifdef _WIN32
		ULONG srcLen =  (ULONG)wcslen(pwszSrc)+1;
		ULONG destLen = srcLen*2;
		dwError = VMCAAllocateMemory((DWORD) destLen, (PVOID*)&pszNewString);
		BAIL_ON_ERROR(dwError);

		if (0 == WideCharToMultiByte(CP_ACP, 0, pwszSrc, -1, pszNewString, destLen, NULL, NULL ))
		{
			dwError = GetLastError();
			BAIL_ON_ERROR(dwError);
		}
		*ppszDst = pszNewString;
cleanup:
		return dwError;

error:
		VMCAFreeMemory(pszNewString);
		goto cleanup;

#else
		dwError = LwNtStatusToWin32Error(
						LwRtlCStringAllocateFromWC16String(ppszDst, pwszSrc));
#endif
	}
	return dwError;
}
Пример #8
0
VOID
VMCAFreeStringArrayA(
    PSTR* ppszStrings,
    DWORD dwCount
    )
{
    if (ppszStrings)
    {
        DWORD dwCnt = 0;

        for (dwCnt = 0; dwCnt < dwCount; dwCnt++)
        {
            if (ppszStrings[dwCnt])
            {
              VMCAFreeStringA(ppszStrings[dwCnt]);
            }
        }

        VMCAFreeMemory(ppszStrings);
    }
}
Пример #9
0
DWORD
VMCAFreeDBEntryFields(
    PVMCA_DB_CERTIFICATE_ENTRY pDBEntry
)
{
    DWORD dwError = 0;
    if(pDBEntry == NULL) {
        dwError = ERROR_INVALID_PARAMETER;
        BAIL_ON_VMCA_ERROR(dwError);
    }

    if( pDBEntry->pwszCommonName) {
        VMCAFreeMemory(pDBEntry->pwszCommonName);
    }

    if( pDBEntry->pwszAltNames) {
        VMCAFreeMemory(pDBEntry->pwszAltNames);
    }

    if( pDBEntry->pwszOrgName) {
        VMCAFreeMemory(pDBEntry->pwszOrgName);
    }

    if( pDBEntry->pwszOrgUnitName) {
        VMCAFreeMemory(pDBEntry->pwszOrgUnitName);
    }

    if( pDBEntry->pwszIssuerName) {
        VMCAFreeMemory(pDBEntry->pwszIssuerName);
    }

    if(pDBEntry->pwszCountryName) {
        VMCAFreeMemory(pDBEntry->pwszCountryName);
    }

    if( pDBEntry->pwszSerial) {
        VMCAFreeMemory(pDBEntry->pwszSerial);
    }


     if ( pDBEntry->pwszTimeValidFrom){
        VMCAFreeMemory(pDBEntry->pwszTimeValidFrom);
    }

    if ( pDBEntry->pwszTimeValidTo){
        VMCAFreeMemory(pDBEntry->pwszTimeValidTo);
    }

    if(pDBEntry->pCertBlob) {
        VMCAFreeMemory(pDBEntry->pCertBlob);
    }

    VMCAFreeMemory(pDBEntry);
    pDBEntry = NULL;
error:
    return dwError;
}
Пример #10
0
VOID
VmcaDbFreeContext(
    PVMCA_DB_CONTEXT pDbContext
    )
{
    while (pDbContext)
    {
        PVMCA_DB_CONTEXT pContext = pDbContext;

        pDbContext = pDbContext->pNext;

        if (pContext->pAddCertQuery)
        {
            sqlite3_finalize(pContext->pAddCertQuery);
        }
        if (pContext->pQueryAllCertificates)
        {
            sqlite3_finalize(pContext->pQueryAllCertificates);
        }
        if (pContext->pQueryCertificatesPaged)
        {
            sqlite3_finalize(pContext->pQueryCertificatesPaged);
        }
        if (pContext->pQueryRevokedCertificates)
        {
            sqlite3_finalize(pContext->pQueryRevokedCertificates);
        }
        if (pContext->pTotalCertCountQuery)
        {
            sqlite3_finalize(pContext->pTotalCertCountQuery);
        }
        if (pContext->pDelCertQuery)
        {
            sqlite3_finalize(pContext->pDelCertQuery);
        }
        if (pContext->pUpdateCertQuery)
        {
            sqlite3_finalize(pContext->pUpdateCertQuery);
        }
        if (pContext->pVerifyCertQuery)
        {
            sqlite3_finalize(pContext->pVerifyCertQuery);
        }
        if (pContext->pGetCertID)
        {
            sqlite3_finalize(pContext->pGetCertID);
        }
        if (pContext->pRevokeCert)
        {
            sqlite3_finalize(pContext->pRevokeCert);
        }
        if (pContext->pRevokedCertCount)
        {
            sqlite3_finalize(pContext->pRevokedCertCount);
        }
        if (pContext->pGetCrlNumber)
        {
            sqlite3_finalize(pContext->pGetCrlNumber);
        }
        if (pContext->pSetCrlNumber)
        {
            sqlite3_finalize(pContext->pSetCrlNumber);
        }

        if (pContext->pDb)
        {
            VmcaDbDatabaseClose(pContext->pDb);
        }

        VMCAFreeMemory(pContext);
    }
}