summaryrefslogtreecommitdiffstats
path: root/media/mtp
diff options
context:
space:
mode:
authorNick Kralevich <nnk@google.com>2012-06-26 13:32:23 -0700
committerNick Kralevich <nnk@google.com>2012-06-26 13:53:00 -0700
commitaf8e8aa1ada2948972555592570ec9ad90cbf372 (patch)
treec573478e9f30dfe62dab9674fa4c04170f4b9626 /media/mtp
parent0dc6d5ef45c0721c76f0e55354ff80371d795e5d (diff)
downloadframeworks_av-af8e8aa1ada2948972555592570ec9ad90cbf372.zip
frameworks_av-af8e8aa1ada2948972555592570ec9ad90cbf372.tar.gz
frameworks_av-af8e8aa1ada2948972555592570ec9ad90cbf372.tar.bz2
Add mode when open(O_CREAT) is used.
When creating a new file using open(..., O_CREAT), it is an error to fail to specify a creation mode. If a mode is not specified, a random stack provided value is used as the "mode". This will become a compile error in a future Android change. Change-Id: I36a3d67d294a915c1f79632a1b0ba45edd1214b1
Diffstat (limited to 'media/mtp')
-rw-r--r--media/mtp/MtpDevice.cpp2
-rw-r--r--media/mtp/MtpServer.cpp2
2 files changed, 2 insertions, 2 deletions
diff --git a/media/mtp/MtpDevice.cpp b/media/mtp/MtpDevice.cpp
index bf7795c..d672dff 100644
--- a/media/mtp/MtpDevice.cpp
+++ b/media/mtp/MtpDevice.cpp
@@ -667,7 +667,7 @@ fail:
// reads the object's data and writes it to the specified file path
bool MtpDevice::readObject(MtpObjectHandle handle, const char* destPath, int group, int perm) {
ALOGD("readObject: %s", destPath);
- int fd = ::open(destPath, O_RDWR | O_CREAT | O_TRUNC);
+ int fd = ::open(destPath, O_RDWR | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR);
if (fd < 0) {
ALOGE("open failed for %s", destPath);
return false;
diff --git a/media/mtp/MtpServer.cpp b/media/mtp/MtpServer.cpp
index 5606187..662a93d 100644
--- a/media/mtp/MtpServer.cpp
+++ b/media/mtp/MtpServer.cpp
@@ -931,7 +931,7 @@ MtpResponseCode MtpServer::doSendObject() {
initialData = ret - MTP_CONTAINER_HEADER_SIZE;
mtp_file_range mfr;
- mfr.fd = open(mSendObjectFilePath, O_RDWR | O_CREAT | O_TRUNC);
+ mfr.fd = open(mSendObjectFilePath, O_RDWR | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR);
if (mfr.fd < 0) {
result = MTP_RESPONSE_GENERAL_ERROR;
goto done;