From b9e5255932c95b9bcae8bd8deaade7f8ca0ed290 Mon Sep 17 00:00:00 2001 From: doronz88 Date: Sun, 22 Sep 2024 08:05:04 +0300 Subject: [PATCH] usbmux: fix handling of bad messages (#1208) Close #1208 --- pymobiledevice3/usbmux.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pymobiledevice3/usbmux.py b/pymobiledevice3/usbmux.py index 363055ac8..615812088 100644 --- a/pymobiledevice3/usbmux.py +++ b/pymobiledevice3/usbmux.py @@ -354,7 +354,11 @@ def get_device_list(self, timeout: float = None) -> None: """ get device list synchronously without waiting the timeout """ self.devices = [] self._send({'MessageType': 'ListDevices'}) - for response in self._receive(self._tag - 1)['DeviceList']: + response = self._receive(self._tag - 1) + device_list = response.get('DeviceList') + if device_list is None: + raise MuxException(f'Got an invalid response from usbmux: {response}') + for response in device_list: if response['MessageType'] == 'Attached': super()._add_device(MuxDevice(response['DeviceID'], response['Properties']['SerialNumber'], response['Properties']['ConnectionType']))