Merge branch 'remote_write_validation' into 'master'

Add validations to remote storage writes

See merge request Mr_Goldberg/goldberg_emulator!22
This commit is contained in:
soft as HELL 2019-10-04 16:01:38 +00:00
commit c7df6deda1
1 changed files with 15 additions and 4 deletions

View File

@ -84,6 +84,11 @@ bool FileWrite( const char *pchFile, const void *pvData, int32 cubData )
{
PRINT_DEBUG("Steam_Remote_Storage::FileWrite %s %u\n", pchFile, cubData);
std::lock_guard<std::recursive_mutex> lock(global_mutex);
if (!pvData || cubData < 0 || cubData > k_unMaxCloudFileChunkSize) {
return false;
}
int data_stored = local_storage->store_data(REMOTE_STORAGE_FOLDER, pchFile, (char* )pvData, cubData);
PRINT_DEBUG("Steam_Remote_Storage::Stored %i, %u\n", data_stored, data_stored == cubData);
return data_stored == cubData;
@ -104,11 +109,17 @@ SteamAPICall_t FileWriteAsync( const char *pchFile, const void *pvData, uint32 c
{
PRINT_DEBUG("Steam_Remote_Storage::FileWriteAsync\n");
std::lock_guard<std::recursive_mutex> lock(global_mutex);
bool success = local_storage->store_data(REMOTE_STORAGE_FOLDER, pchFile, (char* )pvData, cubData) == cubData;
RemoteStorageFileWriteAsyncComplete_t data;
data.m_eResult = k_EResultOK;
return callback_results->addCallResult(data.k_iCallback, &data, sizeof(data));
if (!pvData || cubData > k_unMaxCloudFileChunkSize) {
return k_uAPICallInvalid;
}
bool success = local_storage->store_data(REMOTE_STORAGE_FOLDER, pchFile, (char* )pvData, cubData) == cubData;
RemoteStorageFileWriteAsyncComplete_t data;
data.m_eResult = success ? k_EResultOK : k_EResultFail;
return callback_results->addCallResult(data.k_iCallback, &data, sizeof(data), 0.1);
}