Fixed: Do not open null or empty file paths passed to TermuxOpenReceiver

This commit is contained in:
agnostic-apollo
2022-01-22 18:48:39 +05:00
parent 3898ebdc74
commit b435d94888

View File

@@ -14,6 +14,7 @@ import android.provider.MediaStore;
import android.webkit.MimeTypeMap;
import com.termux.app.utils.PluginUtils;
import com.termux.shared.data.DataUtils;
import com.termux.shared.data.IntentUtils;
import com.termux.shared.net.uri.UriUtils;
import com.termux.shared.logger.Logger;
@@ -74,6 +75,10 @@ public class TermuxOpenReceiver extends BroadcastReceiver {
// Get full path including fragment (anything after last "#")
String filePath = UriUtils.getUriFilePathWithFragment(data);
if (DataUtils.isNullOrEmpty(filePath)) {
Logger.logError(LOG_TAG, "filePath is null or empty");
return;
}
final File fileToShare = new File(filePath);
if (!(fileToShare.isFile() && fileToShare.canRead())) {