Permalink
Browse files

Do not merge.

Hide the content provider and enforce the calling identity.

Bug: 3215801
Change-Id: Id72ee810a32e10e469f4dd64b8c3644e35a9247f
  • Loading branch information...
1 parent 242decf commit 09599d4862289c36586b8fbeb0fb31d40c80ac19 Patrick Scott committed Nov 22, 2010
Showing with 8 additions and 0 deletions.
  1. +1 −0 AndroidManifest.xml
  2. +7 −0 src/com/android/htmlviewer/FileContentProvider.java
View
@@ -38,6 +38,7 @@
</activity>
<provider android:name="FileContentProvider"
+ android:exported="false"
android:authorities="com.android.htmlfileprovider"
android:syncable="false" android:multiprocess="false"
android:grantUriPermissions="true" />
@@ -24,7 +24,9 @@
import android.content.ContentValues;
import android.database.Cursor;
import android.net.Uri;
+import android.os.Binder;
import android.os.ParcelFileDescriptor;
+import android.os.Process;
/**
* WebView does not support file: loading. This class wraps a file load
@@ -47,6 +49,11 @@ public String getType(Uri uri) {
@Override
public ParcelFileDescriptor openFile(Uri uri, String mode) throws FileNotFoundException {
+ // android:exported="false" is broken in older releases so we have to
+ // manually enforce the calling identity.
+ if (Process.myUid() != Binder.getCallingUid()) {
+ throw new SecurityException("Permission denied");
+ }
if (!"r".equals(mode)) {
throw new FileNotFoundException("Bad mode for " + uri + ": " + mode);
}

0 comments on commit 09599d4

Please sign in to comment.