Skip to content

Commit

Permalink
fruity: Fix edge-case in tunnel logic for older OS versions
Browse files Browse the repository at this point in the history
When usbmuxd is not available, we would try to set up a tunnel
connection. This would then fail when the OS is too old for CoreDevice
support, and we would erroneously cache the Tunnel implementation in its
unopened state. This meant it could be used as if it was opened, causing
undefined behavior.

Co-authored-by: Håvard Sørbø <[email protected]>
  • Loading branch information
oleavr and hsorbo committed Oct 28, 2024
1 parent e797e82 commit 2457ac4
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/fruity/device-monitor.vala
Original file line number Diff line number Diff line change
Expand Up @@ -1174,7 +1174,7 @@ namespace Frida.Fruity {

private Promise<UsbDevice>? device_request;
private Promise<LibUSB.Device>? modeswitch_request;
private Promise<Tunnel>? tunnel_request;
private Promise<Tunnel?>? tunnel_request;
private NcmPeer? ncm_peer;

public PortableCoreDeviceUsbTransport (PortableCoreDeviceBackend parent, LibUSB.Device raw_device, string udid,
Expand Down Expand Up @@ -1318,7 +1318,9 @@ namespace Frida.Fruity {
try {
yield tunnel.open (cancellable);
} catch (Error e) {
if (!(e is Error.NOT_SUPPORTED))
if (e is Error.NOT_SUPPORTED)
tunnel = null;
else
throw e;
}
}
Expand Down

0 comments on commit 2457ac4

Please sign in to comment.