From 95083267325f2978bb11f4c4c0167ac1318784d7 Mon Sep 17 00:00:00 2001 From: soft as HELL Date: Thu, 3 Oct 2019 16:17:34 +0300 Subject: [PATCH 1/2] Add validation to writes --- dll/steam_remote_storage.h | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/dll/steam_remote_storage.h b/dll/steam_remote_storage.h index d0c7646..2840abb 100644 --- a/dll/steam_remote_storage.h +++ b/dll/steam_remote_storage.h @@ -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 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,9 +109,15 @@ SteamAPICall_t FileWriteAsync( const char *pchFile, const void *pvData, uint32 c { PRINT_DEBUG("Steam_Remote_Storage::FileWriteAsync\n"); std::lock_guard lock(global_mutex); + + 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 = k_EResultOK; + data.m_eResult = success ? k_EResultOK : k_EResultFail; return callback_results->addCallResult(data.k_iCallback, &data, sizeof(data)); } From 787cac47db64f740fefcf2d992d7fdb829a198fa Mon Sep 17 00:00:00 2001 From: soft as HELL Date: Fri, 4 Oct 2019 19:01:17 +0300 Subject: [PATCH 2/2] Add delay to FileWriteAsync callback --- dll/steam_remote_storage.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dll/steam_remote_storage.h b/dll/steam_remote_storage.h index 2840abb..bc41d6e 100644 --- a/dll/steam_remote_storage.h +++ b/dll/steam_remote_storage.h @@ -119,7 +119,7 @@ SteamAPICall_t FileWriteAsync( const char *pchFile, const void *pvData, uint32 c RemoteStorageFileWriteAsyncComplete_t data; data.m_eResult = success ? k_EResultOK : k_EResultFail; - return callback_results->addCallResult(data.k_iCallback, &data, sizeof(data)); + return callback_results->addCallResult(data.k_iCallback, &data, sizeof(data), 0.1); }