title: ContentProvider Path Traversal Vulnerability
body: <p>Google warns about a path traversal vulnerability in ContentProvider
  <a href="https://support.google.com/faqs/answer/7496913" rel="nofollow noreferrer">https://support.google.com/faqs/answer/7496913</a></p>
  <blockquote>
  <p>Implementations of <code>openFile</code> and <code>openAssetFile</code> in exported <code>ContentProviders</code> can be vulnerable if they do not properly validate incoming <code>Uri</code> parameters. A malicious app can supply a crafted <code>Uri</code> (for example, one that contains “/../”) to trick your app into returning a <code>ParcelFileDescriptor</code> for a file outside of the intended directory, thereby allowing the malicious app to access any file accessible to your app.</p>
  </blockquote>
  <p>Their example (from the above link):</p>
  <pre><code>public ParcelFileDescriptor openFile (Uri uri, String mode)
   throws FileNotFoundException {
   File f = new File(DIR, uri.getLastPathSegment());
    if (!f.getCanonicalPath().startsWith(DIR)) {
      throw new IllegalArgumentException();
    }
   return ParcelFileDescriptor.open(f, ParcelFileDescriptor.MODE_READ_ONLY);
  }
  </code></pre>
  <p>What does the DIR refer to? How do i implement the correct fix?</p>