Skip to content

Commit 68cacc0

Browse files
committed
Fix possible SecurityException when opening PCAP file
Crash in Utils.isPcapng openInputStream
1 parent 5abc3a7 commit 68cacc0

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

app/src/main/java/com/emanuelef/remote_capture/Utils.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1932,7 +1932,7 @@ public static boolean isPcapng(Context ctx, Uri uri) {
19321932
return ((block_type == 0x0A0D0D0A) &&
19331933
((magic == 0x1a2b3c4d) || (magic == 0x4d3c2b1a)));
19341934
}
1935-
} catch (IOException e) {
1935+
} catch (IOException | RuntimeException e) {
19361936
Log.w(TAG, "Reading " + uri + " failed: " + e);
19371937
}
19381938

app/src/main/java/com/emanuelef/remote_capture/activities/MainActivity.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1034,7 +1034,7 @@ private void startOpenPcap(Uri pcap_uri, Uri keylog_uri) {
10341034
mPcapExecutor.execute(() -> {
10351035
try (InputStream in_stream = getContentResolver().openInputStream(pcap_uri)) {
10361036
Utils.copy(in_stream, out);
1037-
} catch (IOException | SecurityException e) {
1037+
} catch (IOException | RuntimeException e) {
10381038
e.printStackTrace();
10391039

10401040
runOnUiThread(() -> {
@@ -1071,7 +1071,7 @@ private void loadKeylogfile(String pcap_path, Uri keylog_uri) {
10711071
// keylog is in a separate file
10721072
try (InputStream in_stream = getContentResolver().openInputStream(keylog_uri)) {
10731073
Utils.copy(in_stream, out);
1074-
} catch (IOException | SecurityException e) {
1074+
} catch (IOException | RuntimeException e) {
10751075
e.printStackTrace();
10761076

10771077
runOnUiThread(() -> {

0 commit comments

Comments
 (0)