diff options
author | android-build-team Robot <android-build-team-robot@google.com> | 2017-11-28 23:32:19 +0000 |
---|---|---|
committer | android-build-team Robot <android-build-team-robot@google.com> | 2017-11-28 23:32:19 +0000 |
commit | c1518e2bf2c8ee5f529e744f1b1f9d6de99f4034 (patch) | |
tree | 4fe3a5eb9a71694d79a4756c1dd85f66542a3d52 | |
parent | f074989f62310a1f3d47fc6e6632314ce6865ca5 (diff) | |
parent | 7ce9f66723ff5f2fd2704ee2fd37e56b72e19bea (diff) | |
download | vold-oreo-m5-release.tar.gz |
Snap for 4448085 from 7ce9f66723ff5f2fd2704ee2fd37e56b72e19bea to oc-m3-releaseandroid-8.1.0_r9android-8.1.0_r7android-8.1.0_r22android-8.1.0_r21android-8.1.0_r18android-8.1.0_r17android-8.1.0_r14android-8.1.0_r13oreo-m5-releaseoreo-m3-release
Change-Id: I8870e695f59155fa1584a8fc0ae71d275227ed74
-rw-r--r-- | EmulatedVolume.cpp | 1 | ||||
-rw-r--r-- | KeyStorage.cpp | 22 | ||||
-rw-r--r-- | KeyUtil.cpp | 2 |
3 files changed, 23 insertions, 2 deletions
diff --git a/EmulatedVolume.cpp b/EmulatedVolume.cpp index df91904a..21b290a9 100644 --- a/EmulatedVolume.cpp +++ b/EmulatedVolume.cpp @@ -84,6 +84,7 @@ status_t EmulatedVolume::doMount() { "-g", "1023", // AID_MEDIA_RW "-m", "-w", + "-G", mRawPath.c_str(), label.c_str(), NULL)) { diff --git a/KeyStorage.cpp b/KeyStorage.cpp index 9d615550..20b23915 100644 --- a/KeyStorage.cpp +++ b/KeyStorage.cpp @@ -35,6 +35,7 @@ #include <android-base/file.h> #include <android-base/logging.h> +#include <android-base/unique_fd.h> #include <cutils/properties.h> @@ -153,10 +154,29 @@ static bool readFileToString(const std::string& filename, std::string* result) { } static bool writeStringToFile(const std::string& payload, const std::string& filename) { - if (!android::base::WriteStringToFile(payload, filename)) { + android::base::unique_fd fd(TEMP_FAILURE_RETRY( + open(filename.c_str(), O_WRONLY | O_CREAT | O_NOFOLLOW | O_TRUNC | O_CLOEXEC, 0666))); + if (fd == -1) { + PLOG(ERROR) << "Failed to open " << filename; + return false; + } + if (!android::base::WriteStringToFd(payload, fd)) { PLOG(ERROR) << "Failed to write to " << filename; + unlink(filename.c_str()); return false; } + // fsync as close won't guarantee flush data + // see close(2), fsync(2) and b/68901441 + if (fsync(fd) == -1) { + if (errno == EROFS || errno == EINVAL) { + PLOG(WARNING) << "Skip fsync " << filename + << " on a file system does not support synchronization"; + } else { + PLOG(ERROR) << "Failed to fsync " << filename; + unlink(filename.c_str()); + return false; + } + } return true; } diff --git a/KeyUtil.cpp b/KeyUtil.cpp index 7bbbf012..dbc73c15 100644 --- a/KeyUtil.cpp +++ b/KeyUtil.cpp @@ -98,7 +98,7 @@ static char const* const NAME_PREFIXES[] = { static std::string keyname(const std::string& prefix, const std::string& raw_ref) { std::ostringstream o; o << prefix << ":"; - for (auto i : raw_ref) { + for (unsigned char i : raw_ref) { o << std::hex << std::setw(2) << std::setfill('0') << (int)i; } return o.str(); |