Page MenuHomePhorge

D8905.1767291008.diff
No OneTemporary

Size
1 KB
Referenced Files
None
Subscribers
None

D8905.1767291008.diff

diff --git a/native/cpp/CommonCpp/Notifications/BackgroundDataStorage/NotificationsCryptoModule.cpp b/native/cpp/CommonCpp/Notifications/BackgroundDataStorage/NotificationsCryptoModule.cpp
--- a/native/cpp/CommonCpp/Notifications/BackgroundDataStorage/NotificationsCryptoModule.cpp
+++ b/native/cpp/CommonCpp/Notifications/BackgroundDataStorage/NotificationsCryptoModule.cpp
@@ -24,6 +24,7 @@
const std::string NotificationsCryptoModule::initialEncryptedMessageContent =
"{\"type\": \"init\"}";
const int NotificationsCryptoModule::olmEncryptedTypeMessage = 1;
+const int temporaryFilePathRandomSuffixLength = 32;
crypto::CryptoModule NotificationsCryptoModule::deserializeCryptoModule(
const std::string &path,
@@ -88,13 +89,12 @@
folly::dynamic::object("account", account)("sessions", sessions);
std::string pickledPersist = folly::toJson(persistJSON);
- std::string temporaryPath = path + callingProcessName;
- // This is for the case if any of the steps below failed/app was killed
- // in a previous call to this method leaving temporary file unremoved.
- // We supply `callingProcessName` as function argument in order to name
- // temporary file in a deterministic way. Otherwise we would need to use
- // directory search API to retrieve unremoved files paths.
- remove(temporaryPath.c_str());
+ std::string temporaryFilePathRandomSuffix =
+ crypto::Tools::generateRandomHexString(
+ temporaryFilePathRandomSuffixLength);
+ std::string temporaryPath =
+ path + callingProcessName + temporaryFilePathRandomSuffix;
+
mode_t readWritePermissionsMode = 0666;
int temporaryFD =
open(temporaryPath.c_str(), O_CREAT | O_WRONLY, readWritePermissionsMode);
@@ -129,6 +129,7 @@
"Details: " +
std::string(strerror(errno)));
}
+ remove(temporaryPath.c_str());
}
void NotificationsCryptoModule::callCryptoModule(

File Metadata

Mime Type
text/plain
Expires
Thu, Jan 1, 6:10 PM (17 h, 47 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5877106
Default Alt Text
D8905.1767291008.diff (1 KB)

Event Timeline