static void * FetchAndVerifyConfigFile(TCascStorage * hs, PQUERY_KEY pFileKey) { TCHAR * szFileName; void * pvListFile = NULL; // Construct the local file name szFileName = CascNewStr(hs->szDataPath, 8 + 3 + 3 + 32); if(szFileName != NULL) { // Add the part where the config file path is AppendConfigFilePath(szFileName, pFileKey); // Load and verify the external listfile pvListFile = ListFile_OpenExternal(szFileName); if(pvListFile != NULL) { if(!ListFile_VerifyMD5(pvListFile, pFileKey->pbData)) { ListFile_Free(pvListFile); pvListFile = NULL; } } // Free the file name CASC_FREE(szFileName); } return pvListFile; }
static int FetchAndVerifyConfigFile(TCascStorage * hs, PQUERY_KEY pFileKey, PQUERY_KEY pFileBlob) { TCHAR * szFileName; int nError; // Construct the local file name szFileName = NewStr(hs->szDataPath, 8 + 3 + 3 + 32); if(szFileName == NULL) return ERROR_NOT_ENOUGH_MEMORY; // Add the part where the config file path is AppendConfigFilePath(szFileName, pFileKey); // Load the config file nError = LoadTextFile(szFileName, pFileBlob); if(nError == ERROR_SUCCESS) { // Verify the blob's MD5 if(!VerifyDataBlockHash(pFileBlob->pbData, pFileBlob->cbData, pFileKey->pbData)) { FreeCascBlob(pFileBlob); nError = ERROR_BAD_FORMAT; } } CASC_FREE(szFileName); return nError; }
static int FetchAndLoadConfigFile(TCascStorage * hs, PQUERY_KEY pFileKey, PARSEINFOFILE PfnParseProc) { TCHAR * szFileName; void * pvListFile = NULL; int nError = ERROR_CAN_NOT_COMPLETE; // Construct the local file name szFileName = CascNewStr(hs->szDataPath, 8 + 3 + 3 + 32); if (szFileName != NULL) { // Add the part where the config file path is AppendConfigFilePath(szFileName, pFileKey); // Load and verify the external listfile pvListFile = ListFile_OpenExternal(szFileName); if (pvListFile != NULL) { if (ListFile_VerifyMD5(pvListFile, pFileKey->pbData)) { nError = PfnParseProc(hs, pvListFile); } else { nError = ERROR_FILE_CORRUPT; } ListFile_Free(pvListFile); } else { nError = ERROR_FILE_NOT_FOUND; } CASC_FREE(szFileName); } else { nError = ERROR_NOT_ENOUGH_MEMORY; } return nError; }