Gallery2: Ensure cropped output is truncated
To properly handle the case that a calling app's use of the crop intent
provides an output URI that already exists, e.g. one that is the same
as the input URI, ensure that writes are truncated.
If any apps are affected by this in practice, it's not clear which;
the generic crop intent does not appear to be widely-used, and calls
from AOSP apps or from the system use temporary files for this.
Change-Id: I2a468d9527b679b6aaef6af1521ec0467f58bf60
diff --git a/src/com/android/gallery3d/filtershow/crop/CropActivity.java b/src/com/android/gallery3d/filtershow/crop/CropActivity.java
index cc8d3e2..d538f89 100644
--- a/src/com/android/gallery3d/filtershow/crop/CropActivity.java
+++ b/src/com/android/gallery3d/filtershow/crop/CropActivity.java
@@ -546,7 +546,7 @@
Utils.closeSilently(mInStream);
if (mOutUri != null) {
try {
- mOutStream = getContentResolver().openOutputStream(mOutUri);
+ mOutStream = getContentResolver().openOutputStream(mOutUri, "wt");
} catch (FileNotFoundException e) {
Log.w(LOGTAG, "cannot write file: " + mOutUri.toString(), e);
}