TeamAmaze / TeamAmaze/AmazeFileManager
[fromContentUri] Null/short path causes substring crash
@wassdak is already working on this.
Since Dec 7, 2025.
- Dominant language
- Kotlin
- Stars
- 6.4k
- Forks
- 1.7k
- Avg merge
- 3d 9h
- Merged PRs (30d)
- 1
Description
Affected Method (full signature):
com.amaze.filemanager.filesystem.files.FileUtils.fromContentUri(@androidx.annotation.NonNull android.net.Uri uri)
Environment:
• AmazeFileManager: stock release/4.0
• Robolectric/JVM
Steps to Reproduce (Robolectric-friendly):
1. Uri u = Uri.parse("content://com.example.provider/x"); (very short path)
2. Call File f = FileUtils.fromContentUri(u);
3. Method performs substring(FILE_PROVIDER_PREFIX.length() + 1) on uri.getPath() without length check.
Expected Behavior:
Validate length and prefix before substring; gracefully reject/return fallback for malformed content URIs.
Actual Behavior:
StringIndexOutOfBoundsException or NullPointerException when getPath() is null/short.
Minimal Input Example:
android.net.Uri u = android.net.Uri.parse("content://com.example.provider/x");
java.io.File f = FileUtils.fromContentUri(u); // crash or invalid
Impact:
Crashes when browsing or opening content documents with atypical but valid URIs.
Suggested Fix:
Guard uri.getPath() for null/length, verify expected prefix before substring, and handle short paths with a safe fallback (or return null/throw a descriptive exception). Prefer robust parsing over fixed offsets.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.